Arkadi w
Arkadi w

Reputation: 89

How to retrieve ggplot2 inner plot size and margins length

I am working on custom ggplot2 items and want to compute the size of the actual plot without the margins.

Suppose this plot

ggplot(mtcars, aes(x = cyl, y = hp )) + geom_point() + ggtitle('test') + theme_bw()

I need to retrive the length (relative or absolute) of the margins (see red lines) or somehow the size of the plot and its relative position to the top left corner.

enter image description here

Is there any way to retrieve this info from the ggplot2 object?

Upvotes: 1

Views: 692

Answers (0)

Related Questions