Skip to content

NULL plot.margin breakdown the shape of the gtable #6234

Closed
@Yunuuuu

Description

@Yunuuuu

Related to #5628

I would like to change this line:

plot_margin <- calc_element("plot.margin", theme)

 plot_margin <- calc_element("plot.margin", theme)  %||% margin()

here is the problem:

copy your code to the clipboard and run:

library(ggplot2)
default_margin <- ggplot(mtcars, aes(disp, mpg)) +
    geom_point()
no_margin <- ggplot(mtcars, aes(disp, mpg)) +
    geom_point() +
    theme(plot.margin = NULL)
length(ggplotGrob(default_margin)$widths)
#> [1] 13
length(ggplotGrob(no_margin)$widths)
#> [1] 11
length(ggplotGrob(default_margin)$heights)
#> [1] 16
length(ggplotGrob(no_margin)$heights)
#> [1] 14

Created on 2024-12-12 with reprex v2.1.0
~
~

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