How can you extract the numbers used to label the y and x axes in the ggplot below (respectively 20, 30, 40
and 10 , 15 ,20 ,25, 30, 35
)?
Extending on the older post - they can be found with
ggplot_build(g)$layout$panel_ranges[[1]]$y.labels
# "20" "30" "40"
ggplot_build(g)$layout$panel_ranges[[1]]$x.labels
# "10" "15" "20" "25" "30" "35"
EDIT: works with ggplot2_2.2.1
but not ggplot2 version 3.0.0
- thanks to zx8754 and nilambara for pointing this out