Skip to content

ggnestedpie does not respect factor order #9

Description

@AlexisDerumigny

Thanks for this package, it is very useful!

I was recently using ggnestedpie but I realized that changing the order of the factor produces the same plot.
Here is an example.

library(ggplot2)
library(ggpie)
data(diamonds)

ggnestedpie(data = diamonds, group_key = c("cut", "color"), count_type = "full")
diamonds$cut = forcats::fct_rev(diamonds$cut)
ggnestedpie(data = diamonds, group_key = c("cut", "color"), count_type = "full")

Both graphs are identical, while my expectation would be that the order of the outer pie in the second one would be reversed compared to the first.

This is the case for the function ggpie.

ggpie(data = diamonds, group_key = c("cut"), count_type = "full")
diamonds$cut = forcats::fct_rev(diamonds$cut)
ggpie(data = diamonds, group_key = c("cut"), count_type = "full")

The inner pie also seems to ignore factor ordering: the following lines seem to produce two identical plots.

ggnestedpie(data = diamonds, group_key = c("cut", "color"), count_type = "full")
diamonds$color = forcats::fct_rev(diamonds$color)
ggnestedpie(data = diamonds, group_key = c("cut", "color"), count_type = "full")

Here is my sessionInfo

R version 4.4.0 Patched (2024-05-06 r86527 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=Dutch_Netherlands.utf8  LC_CTYPE=Dutch_Netherlands.utf8    LC_MONETARY=Dutch_Netherlands.utf8
[4] LC_NUMERIC=C                       LC_TIME=Dutch_Netherlands.utf8    

time zone: Europe/Amsterdam
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggpie_0.2.5   ggplot2_3.5.1

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5        cli_3.6.2          rlang_1.1.4        ggrepel_0.9.5      forcats_1.0.0     
 [6] stringi_1.8.4      generics_0.1.3     labeling_0.4.3     glue_1.7.0         colorspace_2.1-0  
[11] scales_1.3.0       fansi_1.0.6        grid_4.4.0         munsell_0.5.1      tibble_3.2.1      
[16] lifecycle_1.0.4    stringr_1.5.1      compiler_4.4.0     dplyr_1.1.4        RColorBrewer_1.1-3
[21] Rcpp_1.0.12        pkgconfig_2.0.3    rstudioapi_0.16.0  farver_2.1.2       R6_2.5.1          
[26] tidyselect_1.2.1   utf8_1.2.4         pillar_1.9.0       magrittr_2.0.3     tools_4.4.0       
[31] withr_3.0.0        gtable_0.3.5       ggnewscale_0.4.10 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions