Skip to content

Characters in plot title are not bottom-aligned (not sitting on same baseline)? #1010

@jwhendy

Description

@jwhendy

I ran into this a month ago via a work project, then went to reproduce but doubted myself. It looked to me like text was not aligned across the baseline. At the time, I think I was making some plots including a "$" in the axis labels or title, and convinced myself it was the inclusion of a symbol, which I accept might affect the overall line typesetting.

I ran into it again just now, and was able to make an example that shows what I mean:

import pandas as pd
from plotnine import *

df = pd.DataFrame({'x': [0, 1, 2], 'y': [3, 4, 5]})
p = ggplot(df, aes(x='x', y='y')) + geom_point()
p = p + theme_bw(base_size=14) + ggtitle('ABCs')
p
Image

This is in jupyterlab, not sure if that affects things? I used right click > copy cell output to paste into powerpoint so I could crop and zoom in, and then added this red line.

Image

I also changed base_size to 32 and then used p.save() to png and it does still look present (so not just a jupyterlab artifact):

Image

I wondered if it was matplotlib, so I tried an equivalent plot there, but it looks more aligned.

import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [4, 5, 6])
plt.title("ABCs", fontsize=32)
plt.show()
Image

Pasting and cropping, it's slightly there with the C and s a bit closer to the line, but not as exaggerated as via plotnine.

Image

Let me know if there's anything I can help look into or reproduce!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions