Skip to content

Commit 73a2aa5

Browse files
committed
changing figure sizes to histograms in viz
1 parent 341e49d commit 73a2aa5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

viz.Rmd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ To create a histogram in `ggplot2` we will use the `geom_histogram` geometric
10241024
object, setting the `x` axis to the `Speed` measurement variable. As usual,
10251025
let's use the default arguments just to see how things look.
10261026

1027-
```{r 03-data-morley-hist, warning=FALSE, message=FALSE, fig.cap = "Histogram of Michelson's speed of light data."}
1027+
```{r 03-data-morley-hist, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Histogram of Michelson's speed of light data."}
10281028
morley_hist <- ggplot(morley, aes(x = Speed)) +
10291029
geom_histogram()
10301030
@@ -1054,7 +1054,7 @@ Note that
10541054
*vertical lines* are used to denote quantities on the *horizontal axis*,
10551055
while *horizontal lines* are used to denote quantities on the *vertical axis*.
10561056

1057-
```{r 03-data-morley-hist-2, warning=FALSE, message=FALSE,fig.cap = "Histogram of Michelson's speed of light data with vertical line indicating true speed of light."}
1057+
```{r 03-data-morley-hist-2, warning=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", message=FALSE,fig.cap = "Histogram of Michelson's speed of light data with vertical line indicating true speed of light."}
10581058
morley_hist <- ggplot(morley, aes(x = Speed)) +
10591059
geom_histogram() +
10601060
geom_vline(xintercept = 792.458, linetype = "dashed", size = 1)
@@ -1083,7 +1083,7 @@ instead of stacked bars
10831083
(which is the default for bar plots or histograms
10841084
when they are colored by another categorical variable).
10851085

1086-
```{r 03-data-morley-hist-3, warning=FALSE, message=FALSE, fig.cap = "Histogram of Michelson's speed of light data colored by experiment."}
1086+
```{r 03-data-morley-hist-3, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 4.5, fig.align = "center", fig.cap = "Histogram of Michelson's speed of light data colored by experiment."}
10871087
morley_hist <- ggplot(morley, aes(x = Speed, fill = Expt)) +
10881088
geom_histogram(alpha = 0.5, position = "identity") +
10891089
geom_vline(xintercept = 792.458, linetype = "dashed", size = 1.0)
@@ -1107,7 +1107,7 @@ categories. By writing
11071107
and the color will be mapped discretely.
11081108
\index{factor!usage in ggplot}
11091109

1110-
```{r 03-data-morley-hist-with-factor, warning=FALSE, message=FALSE, fig.cap = "Histogram of Michelson's speed of light data colored by experiment as factor."}
1110+
```{r 03-data-morley-hist-with-factor, warning=FALSE, message=FALSE, fig.height = 3.5, fig.width = 5.5, fig.align = "center", fig.cap = "Histogram of Michelson's speed of light data colored by experiment as factor."}
11111111
morley_hist <- ggplot(morley, aes(x = Speed, fill = as_factor(Expt))) +
11121112
geom_histogram(alpha = 0.5, position = "identity") +
11131113
geom_vline(xintercept = 792.458, linetype = "dashed", size = 1.0)
@@ -1146,7 +1146,7 @@ This function allows the column names to be correctly evaluated
11461146
in the context of the data frame.
11471147
\index{ggplot!facet\_grid}
11481148

1149-
```{r 03-data-morley-hist-4, warning=FALSE, message=FALSE, fig.height = 7, fig.cap = "Histogram of Michelson's speed of light data split vertically by experiment."}
1149+
```{r 03-data-morley-hist-4, warning=FALSE, message=FALSE, fig.height = 7, fig.align = "center", fig.cap = "Histogram of Michelson's speed of light data split vertically by experiment."}
11501150
morley_hist <- ggplot(morley, aes(x = Speed, fill = as_factor(Expt))) +
11511151
geom_histogram() +
11521152
facet_grid(rows = vars(Expt)) +
@@ -1171,7 +1171,7 @@ of just how accurate all the experiments were overall. For example, how accurate
11711171
To answer this question, we'll use the `mutate` function to transform our data into a relative measure of accuracy rather than absolute measurements:
11721172
\index{ggplot!labs}\index{ggplot!theme}
11731173

1174-
```{r 03-data-morley-hist-5, warning=FALSE, message=FALSE, fig.height = 7, fig.cap = "Histogram of relative accuracy split vertically by experiment with clearer axes and labels."}
1174+
```{r 03-data-morley-hist-5, warning=FALSE, message=FALSE, fig.height = 7, fig.align = "center", fig.cap = "Histogram of relative accuracy split vertically by experiment with clearer axes and labels."}
11751175
morley_rel <- mutate(morley,
11761176
relative_accuracy = 100 *
11771177
((299000 + Speed) - 299792.458) / (299792.458))
@@ -1227,7 +1227,7 @@ In this case, we can see that both the default number of bins
12271227
and the binwidth of 0.01 are effective for helping answer our question.
12281228
On the other hand, the bin widths of 0.001 and 0.1 are too small and too big, respectively.
12291229

1230-
```{r 03-data-morley-hist-binwidth, echo = FALSE, warning = FALSE, message = FALSE, fig.height = 10, fig.cap = "Effect of varying bin width on histograms."}
1230+
```{r 03-data-morley-hist-binwidth, echo = FALSE, warning = FALSE, message = FALSE, fig.height = 10, fig.align = "center", fig.cap = "Effect of varying bin width on histograms."}
12311231
morley_hist_default <- ggplot(morley_rel,
12321232
aes(x = relative_accuracy,
12331233
fill = as_factor(Expt))) +
@@ -1294,7 +1294,7 @@ For example, if we wanted to add a title to the last plot we created (`morley_hi
12941294
we can use the `+` operator to add a title layer with the `ggtitle` function.
12951295
The result is shown in Figure \@ref(fig:03-data-morley-hist-addlayer).
12961296

1297-
```{r 03-data-morley-hist-addlayer, warning = FALSE, message = FALSE, fig.height = 7, fig.cap = "Histogram of relative accuracy split vertically by experiment with a descriptive title highlighting the take home message of the visualization."}
1297+
```{r 03-data-morley-hist-addlayer, warning = FALSE, message = FALSE, fig.height = 7, fig.align = "center", fig.cap = "Histogram of relative accuracy split vertically by experiment with a descriptive title highlighting the take home message of the visualization."}
12981298
morley_hist_title <- morley_hist +
12991299
ggtitle("Speed of light experiments \n were accurate to about 0.05%")
13001300
@@ -1428,7 +1428,7 @@ scatter plot of
14281428
the [Old Faithful data set](https://www.stat.cmu.edu/~larry/all-of-statistics/=data/faithful.dat) [@faithfuldata],
14291429
shown in Figure \@ref(fig:03-plot-line).
14301430

1431-
```{r 03-plot-line, collapse=TRUE, warning=FALSE, message=FALSE, fig.width = 4.5, fig.height = 3.75, fig.cap = "Scatter plot of waiting time and eruption time."}
1431+
```{r 03-plot-line, collapse=TRUE, warning=FALSE, message=FALSE, fig.width = 3.75, fig.height = 3.5, fig.cap = "Scatter plot of waiting time and eruption time."}
14321432
library(svglite) # we need this to save SVG files
14331433
faithful_plot <- ggplot(data = faithful, aes(x = waiting, y = eruptions)) +
14341434
geom_point() +

0 commit comments

Comments
 (0)