You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
```{r 03-data-co2-scatter, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Scatter plot of atmospheric concentration of CO$_{2}$ over time."}
298
+
```{r 03-data-co2-scatter, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Scatter plot of atmospheric concentration of CO$_{2}$ over time."}
296
299
co2_scatter <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
297
300
geom_point()
298
301
@@ -323,7 +326,7 @@ Let's now try to visualize the `co2_df` as a line plot
323
326
with just the default arguments:
324
327
\index{ggplot!geom\_line}
325
328
326
-
```{r 03-data-co2-line, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time."}
329
+
```{r 03-data-co2-line, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time."}
327
330
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
328
331
geom_line()
329
332
@@ -355,7 +358,7 @@ change the font size, we use the `theme` function with the `text` argument:
355
358
> Interested readers may consult the `theme` function documentation;
356
359
> see the additional resources section at the end of this chapter.
357
360
358
-
```{r 03-data-co2-line-2, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time with clearer axes and labels."}
361
+
```{r 03-data-co2-line-2, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time with clearer axes and labels."}
359
362
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
360
363
geom_line() +
361
364
xlab("Year") +
@@ -388,7 +391,7 @@ to convert the character strings we provide to `c` to `date` vectors.
388
391
> but is not loaded by it.
389
392
> Hence we need to load it separately in the code below.
390
393
391
-
```{r 03-data-co2-line-3, warning = FALSE, message = FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ from 1990 to 1994."}
394
+
```{r 03-data-co2-line-3, warning = FALSE, message = FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ from 1990 to 1994."}
392
395
library(lubridate)
393
396
394
397
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
@@ -505,7 +508,7 @@ We will begin with a scatter plot of the `mother_tongue` and `most_at_home` colu
505
508
The resulting plot is shown in Figure \@ref(fig:03-mother-tongue-vs-most-at-home).
506
509
\index{ggplot!geom\_point}
507
510
508
-
```{r 03-mother-tongue-vs-most-at-home, fig.height=3.5, fig.width = 3.75, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home."}
511
+
```{r 03-mother-tongue-vs-most-at-home, fig.height=5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home."}
509
512
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
510
513
geom_point()
511
514
```
@@ -519,7 +522,7 @@ make the axes labels on the plots more readable.
519
522
\index{escape character} We should also increase the font size to further
520
523
improve readability.
521
524
522
-
```{r 03-mother-tongue-vs-most-at-home-labs, fig.height=3.8, fig.width = 4.5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home with x and y labels."}
525
+
```{r 03-mother-tongue-vs-most-at-home-labs, fig.height=5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home with x and y labels."}
523
526
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
524
527
geom_point() +
525
528
labs(x = "Language spoken most at home \n (number of Canadian residents)",
@@ -584,7 +587,7 @@ to put commas in these numbers to increase their readability.
584
587
We can do this in R by passing the `label_comma` function (from the `scales` package)
585
588
to the `labels` argument of the `scale_x_log10` and `scale_x_log10` functions.
586
589
587
-
```{r 03-mother-tongue-vs-most-at-home-scale, message = FALSE, warning = FALSE, fig.height=3.8, fig.width = 4.5, fig.align = "center", fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home with log adjusted x and y axes."}
590
+
```{r 03-mother-tongue-vs-most-at-home-scale, message = FALSE, warning = FALSE, fig.height=5, fig.align = "center", fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home with log adjusted x and y axes."}
588
591
library(scales)
589
592
590
593
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
@@ -641,7 +644,7 @@ Finally, we will edit the visualization to use the percentages we just computed
```{r 03-mother-tongue-vs-most-at-home-scale-props, fig.height=3.8, fig.width = 4.5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home."}
647
+
```{r 03-mother-tongue-vs-most-at-home-scale-props, fig.height=5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home."}
645
648
ggplot(can_lang, aes(x = most_at_home_percent, y = mother_tongue_percent)) +
646
649
geom_point() +
647
650
labs(x = "Language spoken most at home \n (percentage of Canadian residents)",
@@ -698,7 +701,7 @@ that the `category` column should color the points. Adding this argument will
698
701
color the points according to their group and add a legend at the side of the
699
702
plot.
700
703
701
-
```{r 03-scatter-color-by-category, warning=FALSE, fig.height=4, fig.width = 8, fig.align = "center", fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category."}
704
+
```{r 03-scatter-color-by-category, warning=FALSE, fig.height=5, fig.align = "center", fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category."}
702
705
ggplot(can_lang, aes(x = most_at_home_percent,
703
706
y = mother_tongue_percent,
704
707
color = category)) +
@@ -724,7 +727,7 @@ However, that will not work well for this particular visualization
724
727
because the legend labels are quite long
725
728
and would run off the page if displayed this way.
726
729
727
-
```{r 03-scatter-color-by-category-legend-edit, warning=FALSE, fig.height=5, fig.width = 5.5, fig.align = "center", fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category with the legend edited."}
730
+
```{r 03-scatter-color-by-category-legend-edit, warning=FALSE, fig.height=5.5, fig.align = "center", fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category with the legend edited."}
728
731
ggplot(can_lang, aes(x = most_at_home_percent,
729
732
y = mother_tongue_percent,
730
733
color = category)) +
@@ -770,7 +773,7 @@ this makes the scatter point shapes different for each category. This kind of
770
773
visual redundancy—i.e., conveying the same information with both scatter point color and shape—can
771
774
further improve the clarity and accessibility of your visualization.
772
775
773
-
```{r scatter-color-by-category-palette, fig.height=5, fig.width = 5.5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category with color-blind friendly colors."}
776
+
```{r scatter-color-by-category-palette, fig.height=5.5, fig.align = "center", warning=FALSE, fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home colored by language category with color-blind friendly colors."}
0 commit comments