layer_data output for ggplot's with
geom_hex only provides a
x and a
y variable, which is not the centroid of the hexagons.
I am not sure how this data is used to create the ggplot?? If anyone could enlighten me, it'd be much appreciated.
library(tidyverse) p <- diamonds %>% ggplot() + geom_hex( aes(x = carat, y = price), bins = 10, ) p
p %>% layer_data() %>% tibble()
p + geom_point(aes(x, y), data = layer_data(p))