Fix/communication probably typos (#1439)

* no need for \n before str_wrap(), and a typo

* "col" can work, but may be confusing for readers
This commit is contained in:
Mitsuo Shiota 2023-04-20 09:52:40 +09:00 committed by GitHub
parent 7f2e1d6f19
commit 8c91a43aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -243,13 +243,13 @@ To demonstrate using `annotate()`, let's create some text to add to our plot.
The text is a bit long, so we'll use `stringr::str_wrap()` to automatically add line breaks to it given the number of characters you want per line:
```{r}
trend_text <- "Larger engine sizes tend to\nhave lower fuel economy." |>
trend_text <- "Larger engine sizes tend to have lower fuel economy." |>
str_wrap(width = 30)
trend_text
```
Then, we add two layers of annotation: one with a label geom and the other with a segment geom.
The `x` and `y` aesthetics in both define where the annotation should start, and the `xend` and `yend` aesthetics in the segment annotation define the starting location of the end location of the segment.
The `x` and `y` aesthetics in both define where the annotation should start, and the `xend` and `yend` aesthetics in the segment annotation define the end location of the segment.
Note also that the segment is styled as an arrow.
```{r}
@ -468,10 +468,10 @@ base + theme(legend.position = "right") # the default
base + theme(legend.position = "left")
base +
theme(legend.position = "top") +
guides(col = guide_legend(nrow = 3))
guides(color = guide_legend(nrow = 3))
base +
theme(legend.position = "bottom") +
guides(col = guide_legend(nrow = 3))
guides(color = guide_legend(nrow = 3))
```
If your plot is short and wide, place the legend at the legend at the top or bottom, and if it's tall and narrow, place the legend at the left or right.