thomasp85 / ggforce

Accelerating ggplot2
https://ggforce.data-imaginist.com
Other
916 stars 105 forks source link

order of geom_circle does not hold #296

Closed DSLituiev closed 7 months ago

DSLituiev commented 1 year ago

there seems to be a closed issue #224, but the @HEAD version still does not get this right:

# none of these work:
# remotes::install_github("dmurdoch/ggforce@sortorder")
# remotes::install_github("thomasp85/ggforce")

set.seed(42)
tibble(size=1e-1 * 10^rnorm(10),
         x = rnorm(10),
         y = seq(1,10),
       fill = rbinom(10, 7, 0.2) %>% as.factor()
       ) %>% 
  arrange(-size) %>% 
  ggplot() +
  ggforce::geom_circle(aes(
    y0=y, x0=x, r=size, fill=fill,
    # order=y,
  ), colour = "black",
  ) + 
  geom_text(aes(x=x, y=y, label = y))

image

thomasp85 commented 7 months ago

fixed

thomasp85 commented 7 months ago

The reordering you see is because of the fill mapping which imposes a grouping which, in the end, influences the drawing order. This is a ggplot2 thing, not ggforce