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.width = 5, fig.height = 4, fig.cap = "Scatter plot of atmospheric concentration of CO$_{2}$ over time."}
295
+
```{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."}
296
296
co2_scatter <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
297
297
geom_point()
298
298
@@ -323,7 +323,7 @@ Let's now try to visualize the `co2_df` as a line plot
323
323
with just the default arguments:
324
324
\index{ggplot!geom\_line}
325
325
326
-
```{r 03-data-co2-line, warning=FALSE, message=FALSE, fig.width = 5, fig.height = 4, fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time."}
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."}
327
327
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
328
328
geom_line()
329
329
@@ -355,7 +355,7 @@ change the font size, we use the `theme` function with the `text` argument:
355
355
> Interested readers may consult the `theme` function documentation;
356
356
> see the additional resources section at the end of this chapter.
357
357
358
-
```{r 03-data-co2-line-2, warning=FALSE, message=FALSE, fig.width = 5, fig.height = 4, fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ over time with clearer axes and labels."}
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."}
359
359
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
360
360
geom_line() +
361
361
xlab("Year") +
@@ -388,7 +388,7 @@ to convert the character strings we provide to `c` to `date` vectors.
388
388
> but is not loaded by it.
389
389
> Hence we need to load it separately in the code below.
390
390
391
-
```{r 03-data-co2-line-3, warning = FALSE, message = FALSE, fig.width = 5, fig.height = 4, fig.cap = "Line plot of atmospheric concentration of CO$_{2}$ from 1990 to 1994."}
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."}
392
392
library(lubridate)
393
393
394
394
co2_line <- ggplot(co2_df, aes(x = date_measured, y = ppm)) +
@@ -457,7 +457,7 @@ function with the `waiting` variable on the horizontal axis, the `eruptions`
457
457
variable on the vertical axis, and the `geom_point` geometric object.
458
458
The result is shown in Figure \@ref(fig:03-data-faithful-scatter).
459
459
460
-
```{r 03-data-faithful-scatter, warning=FALSE, message=FALSE, fig.width = 5, fig.height = 4, fig.cap = "Scatter plot of waiting time and eruption time."}
460
+
```{r 03-data-faithful-scatter, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Scatter plot of waiting time and eruption time."}
461
461
faithful_scatter <- ggplot(faithful, aes(x = waiting, y = eruptions)) +
462
462
geom_point()
463
463
@@ -471,7 +471,7 @@ the points are generally nicely visually separated, and the pattern they form
471
471
is clear. In order to refine the visualization, we need only to add axis
472
472
labels and make the font more readable:
473
473
474
-
```{r 03-data-faithful-scatter-2, warning=FALSE, message=FALSE, fig.width = 5, fig.height = 4, fig.cap = "Scatter plot of waiting time and eruption time with clearer axes and labels."}
474
+
```{r 03-data-faithful-scatter-2, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 3.75, fig.align = "center", fig.cap = "Scatter plot of waiting time and eruption time with clearer axes and labels."}
475
475
faithful_scatter <- ggplot(faithful, aes(x = waiting, y = eruptions)) +
476
476
geom_point() +
477
477
labs(x = "Waiting Time (mins)", y = "Eruption Duration (mins)") +
@@ -505,7 +505,7 @@ We will begin with a scatter plot of the `mother_tongue` and `most_at_home` colu
505
505
The resulting plot is shown in Figure \@ref(fig:03-mother-tongue-vs-most-at-home).
506
506
\index{ggplot!geom\_point}
507
507
508
-
```{r 03-mother-tongue-vs-most-at-home, fig.height=5, fig.width = 4, warning=FALSE, fig.cap = "Scatter plot of number of Canadians reporting a language as their mother tongue vs the primary language at home."}
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."}
509
509
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
510
510
geom_point()
511
511
```
@@ -519,7 +519,7 @@ make the axes labels on the plots more readable.
519
519
\index{escape character} We should also increase the font size to further
520
520
improve readability.
521
521
522
-
```{r 03-mother-tongue-vs-most-at-home-labs, fig.height=5, fig.width = 4, 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."}
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."}
523
523
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
524
524
geom_point() +
525
525
labs(x = "Language spoken most at home \n (number of Canadian residents)",
@@ -584,7 +584,7 @@ to put commas in these numbers to increase their readability.
584
584
We can do this in R by passing the `label_comma` function (from the `scales` package)
585
585
to the `labels` argument of the `scale_x_log10` and `scale_x_log10` functions.
586
586
587
-
```{r 03-mother-tongue-vs-most-at-home-scale, message = FALSE, warning = FALSE, fig.height=5, fig.width = 4, 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."}
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."}
588
588
library(scales)
589
589
590
590
ggplot(can_lang, aes(x = most_at_home, y = mother_tongue)) +
@@ -641,7 +641,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=5, fig.width = 4, warning=FALSE, fig.cap = "Scatter plot of percentage of Canadians reporting a language as their mother tongue vs the primary language at home."}
644
+
```{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."}
645
645
ggplot(can_lang, aes(x = most_at_home_percent, y = mother_tongue_percent)) +
646
646
geom_point() +
647
647
labs(x = "Language spoken most at home \n (percentage of Canadian residents)",
@@ -698,7 +698,7 @@ that the `category` column should color the points. Adding this argument will
698
698
color the points according to their group and add a legend at the side of the
699
699
plot.
700
700
701
-
```{r 03-scatter-color-by-category, warning=FALSE, fig.height=5, fig.width = 4, 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."}
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."}
702
702
ggplot(can_lang, aes(x = most_at_home_percent,
703
703
y = mother_tongue_percent,
704
704
color = category)) +
@@ -724,7 +724,7 @@ However, that will not work well for this particular visualization
724
724
because the legend labels are quite long
725
725
and would run off the page if displayed this way.
726
726
727
-
```{r 03-scatter-color-by-category-legend-edit, warning=FALSE, fig.height=5.5, 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."}
727
+
```{r 03-scatter-color-by-category-legend-edit, warning=FALSE, fig.height=5, fig.width = 6, 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
728
ggplot(can_lang, aes(x = most_at_home_percent,
729
729
y = mother_tongue_percent,
730
730
color = category)) +
@@ -770,7 +770,7 @@ this makes the scatter point shapes different for each category. This kind of
770
770
visual redundancy—i.e., conveying the same information with both scatter point color and shape—can
771
771
further improve the clarity and accessibility of your visualization.
772
772
773
-
```{r scatter-color-by-category-palette, fig.height=5.5, 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."}
773
+
```{r scatter-color-by-category-palette, fig.height=5, fig.width = 6, 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