Skip to content

Scaling of plot depends on letter shapes in titles #2476

Closed
@joergtrojan

Description

@joergtrojan

When trying to create two different graphs with identical dimensions, I stumbled across this problem.

Expected behaviour

Scaling of a graph should not depend on which letters are used in main or axis titles.

Actual behaviour

Using g, j, p, q, or y in a title leads to different vertical scaling of the graph.

Suspected cause

The space calculation is probably not based on the font baseline but rather on the absolute letter size. I guess this is a general issue with element_text().

# y-scaling should look exactly the same, but doesn't.
ggplot(mtcars, aes(mpg, wt)) + geom_point() + ggtitle("Title with an h")
ggplot(mtcars, aes(mpg, wt)) + geom_point() + ggtitle("Title with a g")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions