class: title-slide <br> <br> .right-panel[ # More ggplot ## Dr. Mine Dogucu ] --- class: middle .panelset[ .panel[ .panel-name[Plot] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-2-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[English] - Using the `penguins` data, - Map `bill depth` to x-axis, `bill length` to y-axis, `species` to shape and color. - Add a layer of points and set the size of the points to 4. ] .panel[ .panel-name[R] ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) ``` ] ] --- class: middle ## Labs .panelset[ .panel[ .panel-name[Plot] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-4-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[English] - Using the `penguins` data, - Map `bill depth` to x-axis, `bill length` to y-axis, `species` to shape. - Add a layer of points and set the size of the points to 4. - .highlight-text[Add labels to x-axis (Bill Depth(mm)), y-axis (Bill Length(mm)), and the title of the plot (Palmer Penguins).] .panel[ .panel-name[R] ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + * labs(x = "Bill Depth (mm)", * y = "Bill Length (mm)", * title = "Palmer Penguins") ``` ] ] ] --- .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point() + labs(x = "Bill Depth (mm)", y = "Bill Length (mm)", title = "Palmer Penguins") + * theme_bw() ``` ] .right-panel[ ![](03c-more-ggplot_files/figure-html/unnamed-chunk-7-1.png)<!-- --> ] --- class: middle ## Themes .panelset[ .panel[ .panel-name[`theme_gray()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-8-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[`theme_bw()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-9-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[`theme_classic()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-10-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[`theme_dark()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-11-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[`theme_minimal()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-12-1.png" style="display: block; margin: auto;" /> ] .panel[ .panel-name[`theme_void()`] <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-13-1.png" style="display: block; margin: auto;" /> ] ] --- .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point() + labs(x = "Bill Depth (mm)", y = "Bill Length (mm)", title = "Palmer Penguins") + theme_bw() + * theme(text = element_text(size=20)) ``` ] .right-panel[ ![](03c-more-ggplot_files/figure-html/unnamed-chunk-15-1.png)<!-- --> ] --- ```r ?theme ``` --- class: middle .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + * facet_grid(.~species) ``` ] .right-panel[ <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-18-1.png" style="display: block; margin: auto;" /> ] --- class: middle .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + * facet_grid(species~.) ``` ] .right-panel[ <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-20-1.png" style="display: block; margin: auto;" /> ] --- class: middle `library(scales)` .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + scale_x_continuous(breaks = breaks_width(2)) ``` ] .right-panel[ <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-22-1.png" style="display: block; margin: auto;" /> ] --- class: middle `library(scales)` .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + scale_x_continuous(breaks = c(18.5, 20)) ``` ] .right-panel[ <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-24-1.png" style="display: block; margin: auto;" /> ] --- class: middle `library(scales)` .left-panel[ ```r ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, shape = species, color = species)) + geom_point(size = 4) + scale_x_continuous(breaks = c(18.5, 20)) + scale_color_manual(values = c("firebrick", "deepskyblue4", "goldenrod")) ``` ] .right-panel[ <img src="03c-more-ggplot_files/figure-html/unnamed-chunk-26-1.png" style="display: block; margin: auto;" /> ] -- Check out [the ggplot flipbook](https://evamaerey.github.io/ggplot_flipbook/ggplot_flipbook_xaringan.html#1) for some inspiration.