YuLab-SMU / scatterpie

:art: scatter pie plot
https://cran.r-project.org/package=scatterpie
60 stars 15 forks source link

Plot order of pies #7

Closed ekstroem closed 6 years ago

ekstroem commented 6 years ago

Is it possible to change the order that the pies are plotted?

I'd like to plot in the order of decreasing pie radius to ensure that the smallest pies are always printed on top of the larger pies. I tried to order the data frame according to decreasing radius but it appears as if the points are plotted in the order of the x values?

Can I change the plot order?

Thanks for a nice package!

GuangchuangYu commented 6 years ago

sorted_by_radius parameter added in v = 0.0.8.

d = data.frame(x = c(2,2), y = c(2,2.5), A= c(1, 4), B=c(4, 1), r = c(1, 3), g = letters[1:2])
ggplot() + geom_scatterpie(aes(x, y, group=g, r=r), data=d, cols=c('A', 'B'))
ggplot() + geom_scatterpie(aes(x, y, group=g, r=r), data=d, cols=c('A', 'B'), sorted_by_radius=T)
ekstroem commented 6 years ago

Wonderful. Thanks!