A round of edits for length (#1278)
* Move workflow section into Quarto chapter * Delete removed chapter * - Hide figures in exercises - Change eval: false to fig-show: hide * Remove * Fix color scale, closes #1243 * Fix plot size * Reduce image size + formatted excel discussion * Shorten URLs where possible * Fix text running off the page on PDF * Address figure sizing issue * Re-org removes the need for this reference * Remove one plot to reduce redundancy * Read thru * Minor edits * Add ggthemes
This commit is contained in:
committed by
GitHub
parent
be10801648
commit
18419626ed
@@ -49,10 +49,11 @@ library(tidyverse)
|
||||
|
||||
You only need to install a package once, but you need to load it every time you start a new session.
|
||||
|
||||
In addition to tidyverse, we will also use the **palmerpenguins** package, which includes the `penguins` dataset containing body measurements for penguins on three islands in the Palmer Archipelago.
|
||||
In addition to tidyverse, we will also use the **palmerpenguins** package, which includes the `penguins` dataset containing body measurements for penguins on three islands in the Palmer Archipelago, and the ggthemes package, which offers a colorblind safe color palette.
|
||||
|
||||
```{r}
|
||||
library(palmerpenguins)
|
||||
library(ggthemes)
|
||||
```
|
||||
|
||||
## First steps
|
||||
@@ -128,7 +129,8 @@ ggplot(penguins, aes(x = flipper_length_mm, y = body_mass_g)) +
|
||||
y = "Body mass (g)",
|
||||
color = "Species",
|
||||
shape = "Species"
|
||||
)
|
||||
) +
|
||||
scale_color_colorblind()
|
||||
```
|
||||
|
||||
### Creating a ggplot
|
||||
@@ -323,6 +325,7 @@ Note that the legend is automatically updated to reflect the different shapes of
|
||||
And finally, we can improve the labels of our plot using the `labs()` function in a new layer.
|
||||
Some of the arguments to `labs()` might be self explanatory: `title` adds a title and `subtitle` adds a subtitle to the plot.
|
||||
Other arguments match the aesthetic mappings, `x` is the x-axis label, `y` is the y-axis label, and `color` and `shape` define the label for the legend.
|
||||
In addition, we can improve the color palette to be colorblind safe with the `scale_color_colorblind()` function from the ggthemes package.
|
||||
|
||||
```{r}
|
||||
#| warning: false
|
||||
@@ -345,11 +348,10 @@ ggplot(
|
||||
labs(
|
||||
title = "Body mass and flipper length",
|
||||
subtitle = "Dimensions for Adelie, Chinstrap, and Gentoo Penguins",
|
||||
x = "Flipper length (mm)",
|
||||
y = "Body mass (g)",
|
||||
color = "Species",
|
||||
shape = "Species"
|
||||
)
|
||||
x = "Flipper length (mm)", y = "Body mass (g)",
|
||||
color = "Species", shape = "Species"
|
||||
) +
|
||||
scale_color_colorblind()
|
||||
```
|
||||
|
||||
We finally have a plot that perfectly matches our "ultimate goal"!
|
||||
|
||||
Reference in New Issue
Block a user