class: left, top, inverse background-image: url(images/zbysiu-rodak-eod-PZAicYY-unsplash.jpg) background-size: cover # .Large[{ggpattern}] ### An exploration <br>with {flipbookr}<br>and {xaringan} <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> #### .right[[github.com/coolbutuseless/ggpattern](github.com/coolbutuseless/ggpattern)<br>Edited: Gina Reynolds<br>Photo Credit: Zbysiu Rodak in Manta Rota, Portugal] ??? Title slide --- class: center, middle, inverse # {ggpattern} has just been released. --- <blockquote class="twitter-tweet"><p lang="en" dir="ltr">Introducing {ggpattern} - pattern & image fills for <a href="https://twitter.com/hashtag/ggplot?src=hash&ref_src=twsrc%5Etfw">#ggplot</a><br><br>Heaps of fun! Bedazzle those plots!<br><br>My fav: placeholder kittens!<br><br>code: <a href="https://t.co/z5R7GgNLtl">https://t.co/z5R7GgNLtl</a><br><br>Plenty of examples/vignettes are on display on the pkg site: <a href="https://t.co/3ZZ0J0c2qQ">https://t.co/3ZZ0J0c2qQ</a><a href="https://twitter.com/hashtag/RStats?src=hash&ref_src=twsrc%5Etfw">#RStats</a> <a href="https://twitter.com/hashtag/ggpattern?src=hash&ref_src=twsrc%5Etfw">#ggpattern</a> <a href="https://t.co/Y7xq0E4uzE">pic.twitter.com/Y7xq0E4uzE</a></p>— mikefc (@coolbutuseless) <a href="https://twitter.com/coolbutuseless/status/1245098100722630661?ref_src=twsrc%5Etfw">March 31, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> --- class: middle, center, inverse # Lots to explore. -- # Let's see how it works! -- # Contents based on official examples at the package [website](https://coolbutuseless.github.io/package/ggpattern/index.html). --- class: split-40 count: false .column[.content[ ```r *gapminder::gapminder ``` ]] .column[.content[ ``` # A tibble: 1,704 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 1952 28.8 8425333 779. 2 Afghanistan Asia 1957 30.3 9240934 821. 3 Afghanistan Asia 1962 32.0 10267083 853. 4 Afghanistan Asia 1967 34.0 11537966 836. 5 Afghanistan Asia 1972 36.1 13079460 740. 6 Afghanistan Asia 1977 38.4 14880372 786. 7 Afghanistan Asia 1982 39.9 12881816 978. 8 Afghanistan Asia 1987 40.8 13867957 852. 9 Afghanistan Asia 1992 41.7 16317921 649. 10 Afghanistan Asia 1997 41.8 22227415 635. # … with 1,694 more rows ``` ]] --- class: split-40 count: false .column[.content[ ```r gapminder::gapminder %>% * filter(year == 2002) ``` ]] .column[.content[ ``` # A tibble: 142 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 2002 42.1 25268405 727. 2 Albania Europe 2002 75.7 3508512 4604. 3 Algeria Africa 2002 71.0 31287142 5288. 4 Angola Africa 2002 41.0 10866106 2773. 5 Argentina Americas 2002 74.3 38331121 8798. 6 Australia Oceania 2002 80.4 19546792 30688. 7 Austria Europe 2002 79.0 8148312 32418. 8 Bahrain Asia 2002 74.8 656397 23404. 9 Bangladesh Asia 2002 62.0 135656790 1136. 10 Belgium Europe 2002 78.3 10311970 30486. # … with 132 more rows ``` ]] --- class: split-40 count: false .column[.content[ ```r gapminder::gapminder %>% filter(year == 2002) %>% * count(continent) ``` ]] .column[.content[ ``` # A tibble: 5 x 2 continent n <fct> <int> 1 Africa 52 2 Americas 25 3 Asia 33 4 Europe 30 5 Oceania 2 ``` ]] --- class: split-40 count: false .column[.content[ ```r gapminder::gapminder %>% filter(year == 2002) %>% count(continent) -> *continent_count ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_1_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( * aes(pattern_fill = * continent), ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_2_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( aes(pattern_fill = continent), * pattern = "crosshatch", ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_3_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( aes(pattern_fill = continent), pattern = "crosshatch", * fill = "gray95", ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_4_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( aes(pattern_fill = continent), pattern = "crosshatch", fill = "gray95", * colour = "gray35", ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_5_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( aes(pattern_fill = continent), pattern = "crosshatch", fill = "gray95", colour = "gray35", * pattern_color = "white", ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_6_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(ggpattern) ggplot(data = continent_count) + aes(x = continent) + aes(y = n) + ggpattern::geom_col_pattern( aes(pattern_fill = continent), pattern = "crosshatch", fill = "gray95", colour = "gray35", pattern_color = "white", ) + theme_minimal(base_size = 12, base_family = "Courier") + labs(y = NULL) + labs(x = NULL) + labs(title = "Number of countries per continent") + labs(subtitle = "Data: {gapminder} package in R") + theme(legend.position = "none") + labs(caption = "Styling: {ggpattern}") + theme(panel.grid.major.x = element_blank()) + theme(panel.grid.minor.y = element_blank()) + * coord_fixed(ratio = .05) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_plot_non_seq_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r *data.frame(level = c("a", "b", "c", 'd'), * outcome = c(2.3, 1.9, 3.2, 1)) ``` ]] .column[.content[ ``` level outcome 1 a 2.3 2 b 1.9 3 c 3.2 4 d 1.0 ``` ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% * ggplot() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_2_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + * aes(x = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_3_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + * aes(y = outcome) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_4_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + * geom_col_pattern( * fill = 'white', * colour = 'black', * pattern_density = 0.35, * pattern_fill = 'black', * pattern_colour = 'black' * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_5_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + * aes(pattern = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_6_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + * aes(pattern_angle = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + * aes(pattern_spacing = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_8_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + aes(pattern_spacing = level) + * scale_pattern_spacing_discrete(range = c(0.01, 0.05)) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_9_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + aes(pattern_spacing = level) + scale_pattern_spacing_discrete(range = c(0.01, 0.05)) + * coord_fixed(ratio = 1) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_10_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + aes(pattern_spacing = level) + scale_pattern_spacing_discrete(range = c(0.01, 0.05)) + coord_fixed(ratio = 1) + * theme_bw() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_11_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + aes(pattern_spacing = level) + scale_pattern_spacing_discrete(range = c(0.01, 0.05)) + coord_fixed(ratio = 1) + theme_bw() + * labs( * title = "ggpattern::geom_col_pattern()", * subtitle = 'geometry-based patterns' * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_12_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level) + aes(y = outcome) + geom_col_pattern( fill = 'white', colour = 'black', pattern_density = 0.35, pattern_fill = 'black', pattern_colour = 'black' ) + aes(pattern = level) + aes(pattern_angle = level) + aes(pattern_spacing = level) + scale_pattern_spacing_discrete(range = c(0.01, 0.05)) + coord_fixed(ratio = 1) + theme_bw() + labs( title = "ggpattern::geom_col_pattern()", subtitle = 'geometry-based patterns' ) + * theme(legend.position = 'none') ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/multi_pattern_auto_13_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r *data.frame(level = c("a", "b", "c", 'd'), * outcome = c(2.3, 1.9, 3.2, 1)) ``` ]] .column[.content[ ``` level outcome 1 a 2.3 2 b 1.9 3 c 3.2 4 d 1.0 ``` ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% * ggplot() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_2_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + * aes(x = level, y = outcome) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_3_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + * geom_col_pattern( * colour = "black", * pattern_density = 0.35, * pattern_key_scale_factor = 1.3 * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_4_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + * aes(pattern = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_5_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + * aes(fill = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_6_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + * aes(pattern_fill = level) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + * scale_pattern_fill_manual( * values = c(a="blue", b="red", * c="yellow", d="darkgreen")) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_8_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + scale_pattern_fill_manual( values = c(a="blue", b="red", c="yellow", d="darkgreen")) + * theme_bw() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_9_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + scale_pattern_fill_manual( values = c(a="blue", b="red", c="yellow", d="darkgreen")) + theme_bw() + * labs( * title = "ggpattern::geom_col_pattern()", * subtitle = "geometry-based patterns" * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_10_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + scale_pattern_fill_manual( values = c(a="blue", b="red", c="yellow", d="darkgreen")) + theme_bw() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "geometry-based patterns" ) + # overriding x and y to prep for pie * aes(x = "", y = outcome) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_11_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + scale_pattern_fill_manual( values = c(a="blue", b="red", c="yellow", d="darkgreen")) + theme_bw() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "geometry-based patterns" ) + # overriding x and y to prep for pie aes(x = "", y = outcome) + * coord_polar(theta = "y") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_12_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) %>% ggplot() + aes(x = level, y = outcome) + geom_col_pattern( colour = "black", pattern_density = 0.35, pattern_key_scale_factor = 1.3 ) + aes(pattern = level) + aes(fill = level) + aes(pattern_fill = level) + scale_pattern_fill_manual( values = c(a="blue", b="red", c="yellow", d="darkgreen")) + theme_bw() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "geometry-based patterns" ) + # overriding x and y to prep for pie aes(x = "", y = outcome) + coord_polar(theta = "y") + * theme(legend.position = "none") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_color_auto_13_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r *mpg ``` ]] .column[.content[ ``` # A tibble: 234 x 11 manufacturer model displ year cyl trans drv cty hwy fl class <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr> 1 audi a4 1.8 1999 4 auto(l… f 18 29 p comp… 2 audi a4 1.8 1999 4 manual… f 21 29 p comp… 3 audi a4 2 2008 4 manual… f 20 31 p comp… 4 audi a4 2 2008 4 auto(a… f 21 30 p comp… 5 audi a4 2.8 1999 6 auto(l… f 16 26 p comp… 6 audi a4 2.8 1999 6 manual… f 18 26 p comp… 7 audi a4 3.1 2008 6 auto(a… f 18 27 p comp… 8 audi a4 quat… 1.8 1999 4 manual… 4 18 26 p comp… 9 audi a4 quat… 1.8 1999 4 auto(l… 4 16 25 p comp… 10 audi a4 quat… 2 2008 4 manual… 4 20 28 p comp… # … with 224 more rows ``` ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% *ggplot() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_2_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + * aes(class) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_3_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + * geom_bar_pattern( * fill = 'white', * colour = 'black', * pattern_spacing = 0.025 * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_4_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + * aes(pattern = class) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_5_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + * aes(pattern_angle = class) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_6_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + * coord_fixed(ratio = 1/15) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + coord_fixed(ratio = 1/15) + * theme(legend.position = "bottom") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_8_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + coord_fixed(ratio = 1/15) + theme(legend.position = "bottom") + * scale_pattern_discrete(guide = guide_legend(nrow = 3)) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_9_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + coord_fixed(ratio = 1/15) + theme(legend.position = "bottom") + scale_pattern_discrete(guide = guide_legend(nrow = 3)) + * labs(pattern = NULL) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_10_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + coord_fixed(ratio = 1/15) + theme(legend.position = "bottom") + scale_pattern_discrete(guide = guide_legend(nrow = 3)) + labs(pattern = NULL) + * labs(pattern_angle = NULL) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_11_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r mpg %>% ggplot() + aes(class) + geom_bar_pattern( fill = 'white', colour = 'black', pattern_spacing = 0.025 ) + aes(pattern = class) + aes(pattern_angle = class) + coord_fixed(ratio = 1/15) + theme(legend.position = "bottom") + scale_pattern_discrete(guide = guide_legend(nrow = 3)) + labs(pattern = NULL) + labs(pattern_angle = NULL) + * labs(title = "ggpattern::geom_bar_pattern()") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/pattern_bar_auto_12_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r *ggplot(diamonds) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_1_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + * aes(x, y) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_2_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + * xlim(4, 10) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_3_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + * ylim(4, 10) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_4_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + ylim(4, 10) + * geom_point(alpha = .1) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_5_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + ylim(4, 10) + geom_point(alpha = .1) + * geom_bin2d_pattern(pattern_fill = 'magenta', * pattern_color = 'magenta', * bins = 16, * fill = 'lightgrey', * color = "black", * size = 1, * aes(pattern_spacing = ..density..)) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_6_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + ylim(4, 10) + geom_point(alpha = .1) + geom_bin2d_pattern(pattern_fill = 'magenta', pattern_color = 'magenta', bins = 16, fill = 'lightgrey', color = "black", size = 1, aes(pattern_spacing = ..density..)) + * theme_bw(18) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + ylim(4, 10) + geom_point(alpha = .1) + geom_bin2d_pattern(pattern_fill = 'magenta', pattern_color = 'magenta', bins = 16, fill = 'lightgrey', color = "black", size = 1, aes(pattern_spacing = ..density..)) + theme_bw(18) + * scale_pattern_spacing_continuous( * range = c(.03, .01), * trans = "sqrt" * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_8_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(diamonds) + aes(x, y) + xlim(4, 10) + ylim(4, 10) + geom_point(alpha = .1) + geom_bin2d_pattern(pattern_fill = 'magenta', pattern_color = 'magenta', bins = 16, fill = 'lightgrey', color = "black", size = 1, aes(pattern_spacing = ..density..)) + theme_bw(18) + scale_pattern_spacing_continuous( range = c(.03, .01), trans = "sqrt" ) + * labs(title = "ggpattern::geom_bin2d_pattern()") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/bin2d_auto_9_output-1.png" width="432" /> ]] <style type="text/css"> .remark-code{line-height: 1.5; font-size: 80%} </style> --- class: split-40 count: false .column[.content[ ```r *library(maps) ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r library(maps) *library(magick) ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) *states_map <- map_data("state") ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") *state.name ``` ]] .column[.content[ ``` [1] "Alabama" "Alaska" "Arizona" "Arkansas" [5] "California" "Colorado" "Connecticut" "Delaware" [9] "Florida" "Georgia" "Hawaii" "Idaho" [13] "Illinois" "Indiana" "Iowa" "Kansas" [17] "Kentucky" "Louisiana" "Maine" "Maryland" [21] "Massachusetts" "Michigan" "Minnesota" "Mississippi" [25] "Missouri" "Montana" "Nebraska" "Nevada" [29] "New Hampshire" "New Jersey" "New Mexico" "New York" [33] "North Carolina" "North Dakota" "Ohio" "Oklahoma" [37] "Oregon" "Pennsylvania" "Rhode Island" "South Carolina" [41] "South Dakota" "Tennessee" "Texas" "Utah" [45] "Vermont" "Virginia" "Washington" "West Virginia" [49] "Wisconsin" "Wyoming" ``` ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% * tolower() ``` ]] .column[.content[ ``` [1] "alabama" "alaska" "arizona" "arkansas" [5] "california" "colorado" "connecticut" "delaware" [9] "florida" "georgia" "hawaii" "idaho" [13] "illinois" "indiana" "iowa" "kansas" [17] "kentucky" "louisiana" "maine" "maryland" [21] "massachusetts" "michigan" "minnesota" "mississippi" [25] "missouri" "montana" "nebraska" "nevada" [29] "new hampshire" "new jersey" "new mexico" "new york" [33] "north carolina" "north dakota" "ohio" "oklahoma" [37] "oregon" "pennsylvania" "rhode island" "south carolina" [41] "south dakota" "tennessee" "texas" "utah" [45] "vermont" "virginia" "washington" "west virginia" [49] "wisconsin" "wyoming" ``` ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% * data.frame(state = .) ``` ]] .column[.content[ ``` state 1 alabama 2 alaska 3 arizona 4 arkansas 5 california 6 colorado 7 connecticut 8 delaware 9 florida 10 georgia 11 hawaii 12 idaho 13 illinois 14 indiana 15 iowa 16 kansas 17 kentucky 18 louisiana 19 maine 20 maryland 21 massachusetts 22 michigan 23 minnesota 24 mississippi 25 missouri 26 montana 27 nebraska 28 nevada 29 new hampshire 30 new jersey 31 new mexico 32 new york 33 north carolina 34 north dakota 35 ohio 36 oklahoma 37 oregon 38 pennsylvania 39 rhode island 40 south carolina 41 south dakota 42 tennessee 43 texas 44 utah 45 vermont 46 virginia 47 washington 48 west virginia 49 wisconsin 50 wyoming ``` ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% * ggplot() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_7_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + * expand_limits(x = states_map$long, * y = states_map$lat) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_8_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + * aes(map_id = state) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_9_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + * geom_map_pattern( * map = states_map, * pattern_aspect_ratio = 1.75, * fill = 'white', * colour = 'black', * ) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_10_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + geom_map_pattern( map = states_map, pattern_aspect_ratio = 1.75, fill = 'white', colour = 'black', ) + * aes(pattern = state) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_11_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + geom_map_pattern( map = states_map, pattern_aspect_ratio = 1.75, fill = 'white', colour = 'black', ) + aes(pattern = state) + * aes(pattern_spacing = fct_shuffle(state)) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_12_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + geom_map_pattern( map = states_map, pattern_aspect_ratio = 1.75, fill = 'white', colour = 'black', ) + aes(pattern = state) + aes(pattern_spacing = fct_shuffle(state)) + * aes(pattern_fill = fct_shuffle(state)) ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_13_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + geom_map_pattern( map = states_map, pattern_aspect_ratio = 1.75, fill = 'white', colour = 'black', ) + aes(pattern = state) + aes(pattern_spacing = fct_shuffle(state)) + aes(pattern_fill = fct_shuffle(state)) + * theme(legend.position = "none") ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_14_output-1.png" width="432" /> ]] --- class: split-40 count: false .column[.content[ ```r library(maps) library(magick) states_map <- map_data("state") state.name %>% tolower() %>% data.frame(state = .) %>% ggplot() + expand_limits(x = states_map$long, y = states_map$lat) + aes(map_id = state) + geom_map_pattern( map = states_map, pattern_aspect_ratio = 1.75, fill = 'white', colour = 'black', ) + aes(pattern = state) + aes(pattern_spacing = fct_shuffle(state)) + aes(pattern_fill = fct_shuffle(state)) + theme(legend.position = "none") + * coord_map() ``` ]] .column[.content[ <img src="ggpattern_files/figure-html/the_maps_auto_15_output-1.png" width="432" /> ]]