class: inverse, left, bottom background-image: url(https://images.unsplash.com/photo-1621634890180-0b93f32e10bb?q=80&w=1480&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) background-size: cover # .Large[# Pie Charts w/ experimental ggwedge] ## .small[featuring [{ggwedge}] (https://github.com/everyday-analytics/ggwedge)] #### .small[Gina Reynolds | 2023-11-28 |Image credit: Kelly Visel, Upsplash] ??? Title --- ggwedge::geom_pie() sell points - dynamic pie chart creation (counts rows of data (w/ optional weight)) - area of chart is meaningful. Defaults to - required aesthetics make sense (you don't need a "x" or "y" aesthetic, just fill (or alpha, or whatever)) - xy directions don't need to be coordinated (either geom_bar() or coord_polar defaults need to be adjusted to get a pie), since geom_pie anticipates that you'll use the geom w/ polar coordinates. - labeling is relatively easy; positioning can be adjusted with r_prop (recommended) or r_nudge --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r *library(tidyverse) ``` ] .panel2-test-auto[ ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) *library(ggwedge) ``` ] .panel2-test-auto[ ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) *ggplot2::diamonds ``` ] .panel2-test-auto[ ``` ## # A tibble: 53,940 × 10 ## carat cut color clarity depth table price x y z ## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl> ## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 ## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 ## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 ## 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63 ## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 ## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 ## 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47 ## 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53 ## 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49 ## 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39 ## # ℹ 53,930 more rows ``` ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% * ggplot() ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_04_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + * ggwedge:::geom_pie() ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_05_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + * coord_polar() ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_06_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + * theme_void() ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_07_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + * aes(fill = color) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_08_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + * ggwedge:::geom_pie_label(r_prop = 1.2) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_09_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + * facet_wrap(~cut) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_10_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + facet_wrap(~cut) + * aes(alpha = color) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_11_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + facet_wrap(~cut) + aes(alpha = color) + * aes(alpha = NULL) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_12_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + facet_wrap(~cut) + aes(alpha = color) + aes(alpha = NULL) + * aes(r = 1) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_13_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + facet_wrap(~cut) + aes(alpha = color) + aes(alpha = NULL) + aes(r = 1) + * facet_null() ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_14_output-1.png)<!-- --> ] --- count: false ### Example 1: ggplot2 calcs under the hood .panel1-test-auto[ ```r library(tidyverse) library(ggwedge) ggplot2::diamonds %>% ggplot() + ggwedge:::geom_pie() + coord_polar() + theme_void() + aes(fill = color) + ggwedge:::geom_pie_label(r_prop = 1.2) + facet_wrap(~cut) + aes(alpha = color) + aes(alpha = NULL) + aes(r = 1) + facet_null() + * ggwedge:::geom_pie_label( * aes(label = after_stat(weight), * angle = after_stat(c(0,0,0,0,0,0,-85)), * color = after_scale(c(rep("white",6),"black"))), * r_prop = .7) ``` ] .panel2-test-auto[ ![](ggwedge-geom-pie_files/figure-html/test_auto_15_output-1.png)<!-- --> ] <style> .panel1-test-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-test-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-test-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # DIY aggregation: aggregate before entering plot space --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r *ggplot2::diamonds ``` ] .panel2-count_yourself-auto[ ``` ## # A tibble: 53,940 × 10 ## carat cut color clarity depth table price x y z ## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl> ## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 ## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 ## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 ## 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63 ## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 ## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 ## 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47 ## 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53 ## 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49 ## 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39 ## # ℹ 53,930 more rows ``` ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% * count(cut) ``` ] .panel2-count_yourself-auto[ ``` ## # A tibble: 5 × 2 ## cut n ## <ord> <int> ## 1 Fair 1610 ## 2 Good 4906 ## 3 Very Good 12082 ## 4 Premium 13791 ## 5 Ideal 21551 ``` ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% count(cut) %>% * ggplot() ``` ] .panel2-count_yourself-auto[ ![](ggwedge-geom-pie_files/figure-html/count_yourself_auto_03_output-1.png)<!-- --> ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% count(cut) %>% ggplot() + * aes(fill = cut, weight = n) ``` ] .panel2-count_yourself-auto[ ![](ggwedge-geom-pie_files/figure-html/count_yourself_auto_04_output-1.png)<!-- --> ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% count(cut) %>% ggplot() + aes(fill = cut, weight = n) + * ggwedge:::geom_pie() ``` ] .panel2-count_yourself-auto[ ![](ggwedge-geom-pie_files/figure-html/count_yourself_auto_05_output-1.png)<!-- --> ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% count(cut) %>% ggplot() + aes(fill = cut, weight = n) + ggwedge:::geom_pie() + * coord_polar() ``` ] .panel2-count_yourself-auto[ ![](ggwedge-geom-pie_files/figure-html/count_yourself_auto_06_output-1.png)<!-- --> ] --- count: false ### Example 2: do your own aggregations .panel1-count_yourself-auto[ ```r ggplot2::diamonds %>% count(cut) %>% ggplot() + aes(fill = cut, weight = n) + ggwedge:::geom_pie() + coord_polar() + * ggwedge:::geom_pie_label( * aes(label = after_stat(weight), * angle = after_stat(c(85,0,0,0,0))), * r_prop = .7, * color = "oldlace") ``` ] .panel2-count_yourself-auto[ ![](ggwedge-geom-pie_files/figure-html/count_yourself_auto_07_output-1.png)<!-- --> ] <style> .panel1-count_yourself-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-count_yourself-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-count_yourself-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # to do... - look at coord_radial and that interaction - make geom_wedge which is cartesian coordinates (naive (?) crossing approach that works in 'step 0' base ggplot2 build, fails in stat creation.) - make geom_pie_label variants helpers...; where stat calculates label based on some specification geom_pie_label(type = c("count", "percent", "count (percent)", "percent (count)", "fill", etc)... --- ## 'Real world' application: TidyTuesday Rladies ```r # tidytuesday data rladies_chapters <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-11-21/rladies_chapters.csv') ``` --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r *library(tidyverse) ``` ] .panel2-feature-auto[ ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) *library(ggwedge) ``` ] .panel2-feature-auto[ ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) *rladies_chapters ``` ] .panel2-feature-auto[ ``` ## # A tibble: 4,268 × 6 ## id chapter title date location year ## <dbl> <chr> <chr> <date> <chr> <dbl> ## 1 296275584 rladies-st-louis "Save the date! Introd… 2023-11-30 online 2023 ## 2 296277517 rladies-coventry "An basic introduction… 2023-11-30 online 2023 ## 3 295898711 rladies-baltimore "Holiday graphics and … 2023-11-28 inperson 2023 ## 4 296346610 rladies-philly "TidyTuesday with R-La… 2023-11-14 online 2023 ## 5 296275461 rladies-st-louis "Save the date! Introd… 2023-11-08 online 2023 ## 6 296424871 rladies-kathmandu "4 days workshop" 2023-11-01 inperson 2023 ## 7 296239571 rladies-taipei "旅遊服務銜接 AIGC 的… 2023-10-30 inperson 2023 ## 8 296559481 rladies-montreal "RLadies October Meetu… 2023-10-30 inperson 2023 ## 9 296677321 rladies-abuja "R-Ladies Abuja and Ab… 2023-10-28 inperson 2023 ## 10 296720878 rladies-sao-paulo "Meetup R-Ladies São P… 2023-10-28 inperson 2023 ## # ℹ 4,258 more rows ``` ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% * filter(year == 2020) ``` ] .panel2-feature-auto[ ``` ## # A tibble: 920 × 6 ## id chapter title date location year ## <dbl> <chr> <chr> <date> <chr> <dbl> ## 1 250503965 rladies-guayaquil ¡Primer meet-up R-Ladi… 2020-12-30 inperson 2020 ## 2 275174364 rladies-dc Happy hour and year in… 2020-12-29 online 2020 ## 3 275260700 rladies-colombo R Markdown: ON YOUR MA… 2020-12-28 online 2020 ## 4 274731745 rladies-dc Movie night: TBD 2020-12-26 online 2020 ## 5 275171538 rladies-rotterdam Microbenchmarking: mea… 2020-12-22 online 2020 ## 6 275209539 rladies-jujuy ¡Fin de año y primer m… 2020-12-21 online 2020 ## 7 274731734 rladies-dc Movie night: TBD 2020-12-19 online 2020 ## 8 274961085 rladies-amsterdam Automatic & Explainabl… 2020-12-17 online 2020 ## 9 275130932 rladies-montreal R-Ladies Meeting: TBC 2020-12-17 inperson 2020 ## 10 274927239 rladies-montreal R-Ladies Meeting: TBC 2020-12-17 inperson 2020 ## # ℹ 910 more rows ``` ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% * ggplot() ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_05_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + * ggwedge:::geom_pie(color = "snow", * linewidth = .25) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_06_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + * aes(fill = location) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_07_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + * coord_polar(clip = "on") ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_08_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + coord_polar(clip = "on") + * theme(axis.text.x = element_blank()) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_09_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + coord_polar(clip = "on") + theme(axis.text.x = element_blank()) + * ggwedge:::geom_pie_label(r_prop = 1.2, * color = "gray20", * size = 2) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_10_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + coord_polar(clip = "on") + theme(axis.text.x = element_blank()) + ggwedge:::geom_pie_label(r_prop = 1.2, color = "gray20", size = 2) + * facet_wrap(~month(date, label = T, abbr = T), * nrow = 3) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_11_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + coord_polar(clip = "on") + theme(axis.text.x = element_blank()) + ggwedge:::geom_pie_label(r_prop = 1.2, color = "gray20", size = 2) + facet_wrap(~month(date, label = T, abbr = T), nrow = 3) + * scale_fill_manual(values = c("Plum3", "Magenta")) ``` ] .panel2-feature-auto[ ![](ggwedge-geom-pie_files/figure-html/feature_auto_12_output-1.png)<!-- --> ] --- count: false ## Make pies for RLadies attendance .panel1-feature-auto[ ```r library(tidyverse) library(ggwedge) rladies_chapters %>% filter(year == 2020) %>% ggplot() + ggwedge:::geom_pie(color = "snow", linewidth = .25) + aes(fill = location) + coord_polar(clip = "on") + theme(axis.text.x = element_blank()) + ggwedge:::geom_pie_label(r_prop = 1.2, color = "gray20", size = 2) + facet_wrap(~month(date, label = T, abbr = T), nrow = 3) + scale_fill_manual(values = c("Plum3", "Magenta")) -> *a_nice_plot ``` ] .panel2-feature-auto[ ] <style> .panel1-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-feature-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false ## Style plot .panel1-style-auto[ ```r *a_nice_plot ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_01_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + * theme(plot.title.position = "plot") ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_02_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + * labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_03_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") + * labs(subtitle = "There was also a drop in the number of April/May meetings.\n") ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_04_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") + labs(subtitle = "There was also a drop in the number of April/May meetings.\n") + * theme_void() ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_05_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") + labs(subtitle = "There was also a drop in the number of April/May meetings.\n") + theme_void() + * theme( * plot.title = ggtext::element_textbox_simple( * size = 14, lineheight = 1, padding = margin(0, 0, 5, 0) * ) * ) ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_06_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") + labs(subtitle = "There was also a drop in the number of April/May meetings.\n") + theme_void() + theme( plot.title = ggtext::element_textbox_simple( size = 14, lineheight = 1, padding = margin(0, 0, 5, 0) ) ) + * theme(text = element_text(color = "grey55")) ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_07_output-1.png)<!-- --> ] --- count: false ## Style plot .panel1-style-auto[ ```r a_nice_plot + theme(plot.title.position = "plot") + labs(title = "R-Ladies meetings in 2020 moved from mostly <span style = 'color:Plum3;'>in person</span> to mostly <span style = 'color:Magenta;'>online</span>.") + labs(subtitle = "There was also a drop in the number of April/May meetings.\n") + theme_void() + theme( plot.title = ggtext::element_textbox_simple( size = 14, lineheight = 1, padding = margin(0, 0, 5, 0) ) ) + theme(text = element_text(color = "grey55")) + * theme(legend.position = "none") ``` ] .panel2-style-auto[ ![](ggwedge-geom-pie_files/figure-html/style_auto_08_output-1.png)<!-- --> ] <style> .panel1-style-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-style-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-style-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ![](ggwedge-geom-pie_files/figure-html/style-1.png)<!-- --> --- ### Contribute - https://github.com/everyday-analytics/ggwedge --- ### There are many other approaches to pies. - base ggplot2: https://r-graph-gallery.com/piechart-ggplot2.html, aan be used on aggregates or raw data (stat_count is at work in the background) - ggforce https://ggforce.data-imaginist.com/reference/geom_arc_bar.html cartesian coords, highly flexible, requires many aesthetics, no auto label, requires pre-aggregation - ggpie #1 https://github.com/showteeth/ggpie wrapping style ggplot2 extension ggpie (data, group_key, count_type, fill_color) - ggpie #2 https://github.com/Rkabacoff/ggpie wrapping style - ggpie #3 https://github.com/marcuslehr/ggpie not a package, just a little script in a repo on github - ggtricks https://github.com/AbdoulMa/ggtricks geom_pie cartesian, requires pre-aggregation --- ### Check out flipbookr, used to build this featurette - https://github.com/EvaMaeRey/flipbookr - discussion: https://github.com/EvaMaeRey/flipbookr/blob/master/docs/draft_jasa_submission.pdf --- ### Check out more featurettes - https://EvaMaeRey.github.io/featurette <style type="text/css"> .remark-code{line-height: 1.5; font-size: 100%} @media print { .has-continuation { display: block; } } </style>