For geom_hex, how does the layer_data relate to the plot?

The 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.


p <- diamonds %>%
  ggplot() +
    aes(x = carat, y = price),
    bins = 10, 


p %>% layer_data() %>% tibble()

p + 
  geom_point(aes(x, y), data = layer_data(p))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.