class: center, middle, inverse, title-slide # Geom specific, data, aesthetic mapping, unmapped aesthetics ### Gina Reynolds, July 2019 --- --- name: local # The conditional mood: geom specific data, aesthetic mapping, and unmapped aesthetics The conditional mood is about "if". "If I see flowers, then I pick them." In ggplot, we also observe such conditionality. Data and aesthetic mappings may be tied to *specific* geometric objects. Also aesthetics that don't do any representation (unmapped aesthetics) may also be specified on a geom-by-geom basis. These specifications are "local" to a geom, rather than globally defined like the data declarations and aesthetic mapping statements we have seen before. --- ## Part i. Going *local* with data Let's look at tying some data to a specific geometric object in the next example. In this example you'll also see how a 'variable' can be created *on the fly*. --- class: split-40 count: false .left-panel-local_data-auto[ ```r *gapminder ``` ] .right-panel-local_data-auto[ ``` # 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 .left-panel-local_data-auto[ ```r gapminder %>% * filter(year == 2002) ``` ] .right-panel-local_data-auto[ ``` # 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 .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> *gm_2002 ``` ] .right-panel-local_data-auto[ ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 *gm_2002 ``` ] .right-panel-local_data-auto[ ``` # 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 .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% * filter(continent == "Oceania") ``` ] .right-panel-local_data-auto[ ``` # A tibble: 2 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Australia Oceania 2002 80.4 19546792 30688. 2 New Zealand Oceania 2002 79.1 3908037 23190. ``` ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> *gm_2002_europe ``` ] .right-panel-local_data-auto[ ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe *ggplot(data = gm_2002) # global data ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_7_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data * aes(x = gdpPercap) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_8_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + * aes(y = lifeExp) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_9_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + * geom_point() ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_10_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + * aes(color = continent) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_11_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 * aes(xend = 0) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_12_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 * aes(yend = 0) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_13_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-local_data-auto[ ```r gapminder %>% filter(year == 2002) -> gm_2002 gm_2002 %>% filter(continent == "Oceania") -> gm_2002_europe ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 aes(yend = 0) + # geom specific data * geom_segment(data = gm_2002_europe) ``` ] .right-panel-local_data-auto[ <img src="local_files/figure-html/local_data_auto_14_output-1.png" width="100%" /> ] <style> .left-panel-local_data-auto { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-local_data-auto { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-local_data-auto { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- ### Adjusting within call --- class: split-40 count: false #### Manipulating data locally .left-panel-local_data_filter-1[ ```r gapminder %>% filter(year == 2002) -> gm_2002 ggplot(data = gm_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 aes(yend = 0) + # geom specific data * geom_segment(data = gm_2002 %>% filter(continent == "Oceania")) ``` ] .right-panel-local_data_filter-1[ <img src="local_files/figure-html/local_data_filter_1_1_output-1.png" width="100%" /> ] <style> .left-panel-local_data_filter-1 { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-local_data_filter-1 { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-local_data_filter-1 { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- class: split-40 count: false #### Referring to global data locally using period (.) .left-panel-local_data_from_global-1[ ```r *gapminder %>% * filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + geom_point() + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 aes(yend = 0) + # geom specific data * geom_segment(data = . %>% filter(continent == "Oceania")) ``` ] .right-panel-local_data_from_global-1[ <img src="local_files/figure-html/local_data_from_global_1_1_output-1.png" width="100%" /> ] <style> .left-panel-local_data_from_global-1 { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-local_data_from_global-1 { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-local_data_from_global-1 { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## Part ii. geom specific aesthetic representation So far we have seen aesthetic "mapping" (representation) applied globally --- where aes() is an independent statement. In this case aesthetic representation is applied to all geoms. However, we can be specific about which geoms should take on the aesthetic representation, if we use aes() within the geom_*() statement. This local aesthetic mapping declaration will overwrite An example is shown below. --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics geom_point() ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_1_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(color = gdpPercap)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_2_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(size = gdpPercap)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_3_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(size = pop)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_4_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(color = gdpPercap, size = pop)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_5_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(color = gdpPercap, x = gdpPercap/2)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_6_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-geom_specific_aes_mapping-rotate[ ```r ggplot(data = gapminder_2002_europe) + # global aesthetics aes(x = gdpPercap) + aes(y = lifeExp) + aes(xend = 0) + # required aes for segment aes(yend = 0) + # required aes for segment geom_segment() + # geom specific aesthetics * geom_point(aes(color = gdpPercap, y = 0)) ``` ] .right-panel-geom_specific_aes_mapping-rotate[ <img src="local_files/figure-html/geom_specific_aes_mapping_rotate_7_output-1.png" width="100%" /> ] <style> .left-panel-geom_specific_aes_mapping-rotate { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-geom_specific_aes_mapping-rotate { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-geom_specific_aes_mapping-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## Part iii. Being a dictator -- unmapped aesthetics (Imparative mode) *Mapped* aesthetics contrast with unmapped, across-the-board, aesthetics for a geometric object. geom_point(color = "blue"), is an imperative -- not an ask. A dictator move. "Do this everywhere." It is good to show a plot with two of the same geom layer, one with mapped aesthetics and the other without. --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: geom_point() ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_1_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "plum4") ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_2_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "steelblue") ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_3_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "#0FF3F3") ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_4_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(size = 7) ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_5_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(alpha = .5) ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_6_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "plum4", size = 7) ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_7_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "plum4", size = 7, alpha = .5) ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_8_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-unmapped_aes-rotate[ ```r gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = gdpPercap) + aes(y = lifeExp) + # Another geometric layer with aesthetics # that don't do representation: * geom_point(color = "firebrick", size = 7, alpha = .8, shape = "square") ``` ] .right-panel-unmapped_aes-rotate[ <img src="local_files/figure-html/unmapped_aes_rotate_9_output-1.png" width="100%" /> ] <style> .left-panel-unmapped_aes-rotate { color: #777; width: 59%; height: 92%; float: left; font-size: 80% } .right-panel-unmapped_aes-rotate { width: 40%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-unmapped_aes-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Combinations of local and global data, aesthetics Now you know about *global* and *local* data, aesthetic representing variables, and overwriting defaults for aesthetics doing no variable representation. Let's think about combining these. --- Look at the code that follows. What are your expectations for the result? Move forward in the presentation to check if your expectations match the actual result. --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r *ggplot(data = gapminder_2002) # global data ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_1_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data * aes(x = gdpPercap) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_2_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + * aes(y = lifeExp) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_3_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + * geom_point(size = 5, * alpha = .7) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_4_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point(size = 5, alpha = .7) + * aes(color = continent) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_5_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point(size = 5, alpha = .7) + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 * aes(xend = 0) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_6_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point(size = 5, alpha = .7) + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 * aes(yend = 0) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_7_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-all_conditional-auto[ ```r ggplot(data = gapminder_2002) + # global data aes(x = gdpPercap) + aes(y = lifeExp) + geom_point(size = 5, alpha = .7) + aes(color = continent) + # xend and yend are required for geom_segment # like creating a column with a single value, 0 aes(xend = 0) + # like creating a column with a single value, 0 aes(yend = 0) + # geom specific data * geom_segment( * data = gapminder_2002_europe, * aes(size = gdpPercap, * alpha = pop), * color = "orange" * ) ``` ] .right-panel-all_conditional-auto[ <img src="local_files/figure-html/all_conditional_auto_8_output-1.png" width="100%" /> ] <style> .left-panel-all_conditional-auto { color: #777; width: 38.6138613861386%; height: 92%; float: left; font-size: 80% } .right-panel-all_conditional-auto { width: 59.4059405940594%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-all_conditional-auto { width: 0%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Advanced aes --- conflicting desires for color and fill, for example --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + geom_col(aes(color = continent)) ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_1_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent, fill = after_scale(color))) ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_2_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent, fill = after_scale(alpha(color, .4)))) ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_3_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent), fill = NA) ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_4_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent, fill = NULL)) ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_5_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-aes_after-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent), fill = "snow1") ``` ] .right-panel-aes_after-rotate[ <img src="local_files/figure-html/aes_after_rotate_6_output-1.png" width="100%" /> ] <style> .left-panel-aes_after-rotate { color: #777; width: 59%; height: 92%; float: left; font-size: 80% } .right-panel-aes_after-rotate { width: 40%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-aes_after-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Even more control with stage in the example we see how we can get transparency for outline. alpha aes, usually refers to --- class: split-40 count: false .left-panel-stage-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + geom_col() ``` ] .right-panel-stage-rotate[ <img src="local_files/figure-html/stage_rotate_1_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-stage-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent)) ``` ] .right-panel-stage-rotate[ <img src="local_files/figure-html/stage_rotate_2_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-stage-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = continent), size = 3) ``` ] .right-panel-stage-rotate[ <img src="local_files/figure-html/stage_rotate_3_output-1.png" width="100%" /> ] --- class: split-40 count: false .left-panel-stage-rotate[ ```r gapminder_2002 %>% count(continent) %>% ggplot() + aes(x = continent) + aes(y = n) + * geom_col(aes(color = stage(start = continent, after_scale = alpha(color, 0.5))), size = 3) ``` ] .right-panel-stage-rotate[ <img src="local_files/figure-html/stage_rotate_4_output-1.png" width="100%" /> ] <style> .left-panel-stage-rotate { color: #777; width: 79%; height: 92%; float: left; font-size: 80% } .right-panel-stage-rotate { width: 20%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-stage-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> <style type="text/css"> .remark-code{line-height: 1.5; font-size: 60%} </style>