If I want to check what the range for the size scale is set to for the plot below, how can I do that in ggplot?
plt <- ggplot(mpg, aes(displ, hwy, size = hwy)) +
geom_point() +
scale_size(range = c(0, 5))
plt
For x
and y
I can use layer_scales(plt)$x$range$range
from How can I extract plot axes' ranges for a ggplot2 object?, but for some reason using the same approach does not work with e.g. size and color. I have also tried plt$scales$get_scales('size')
which cryptically returns another range for the scale that what is actually used in the plot:
<ScaleContinuous>
Range:
Limits: 0 -- 1