Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions annotations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The main tool for labelling plots is `geom_text()`, which adds `label` text at t

- extrafont, <https://github.com/wch/extrafont>, by Winston Chang, converts fonts to a standard format that all devices can use.

Both approaches have pros and cons, so you will to need to try both of them and see which works best for your needs.
Both approaches have pros and cons, so you will need to try both of them and see which works best for your needs.
\index{Font!family}

- The `fontface` aesthetic specifies the face, and can take three values: "plain" (the default), "bold" or "italic".
Expand All @@ -114,7 +114,7 @@ The main tool for labelling plots is `geom_text()`, which adds `label` text at t
```

- You can adjust the alignment of the text with the `hjust` ("left", "center", "right", "inward", "outward") and `vjust` ("bottom", "middle", "top", "inward", "outward") aesthetics.
The aligment is centered by default, but there are often good reasons to override this.
The alignment is centered by default, but there are often good reasons to override this.
One of the most useful alignments is "inward".
It aligns text towards the middle of the plot, which ensures that labels remain within the plot limits: \index{Font!justification}

Expand All @@ -139,7 +139,7 @@ The main tool for labelling plots is `geom_text()`, which adds `label` text at t
- The font size is controlled by the `size` aesthetic.
Unlike most tools, ggplot2 specifies the size in millimeters (mm), rather than the usual points (pts).
The reason for this choice is that it makes it the units for font sizes consistent with how other sizes are specified in ggplot2.
(There are 72.27 pts in a inch, so to convert from points to mm, just multiply by 25.4 / 72.27).
(There are 72.27 pts in an inch, so to convert from points to mm, just multiply by 25.4 / 72.27).
\index{Font!size}

- `angle` specifies the rotation of the text in degrees.
Expand Down Expand Up @@ -405,7 +405,7 @@ ggplot(mpg, aes(displ, hwy)) +
```

A third approach to direct labelling is provided in the gghighlight package by Hiroaki Yutani <https://github.com/yutannihilation/gghighlight>.
In many situations is useful for highlighting points or lines (or indeed a variety of different geoms) within a plot, particularly for longitudinal data:
In many situations it is useful for highlighting points or lines (or indeed a variety of different geoms) within a plot, particularly for longitudinal data:

```{r}
#| label: gghighlight
Expand Down Expand Up @@ -441,8 +441,8 @@ ggplot(diamonds, aes(log10(carat), log10(price))) +
facet_wrap(vars(cut), nrow = 1)
```

In this plot, each facet displays the data for one category agains the same regression line.
This makes it easier to compare the facets to each other because there is shared reference line to assist the visual comparison.
In this plot, each facet displays the data for one category against the same regression line.
This makes it easier to compare the facets to each other because there is a shared reference line to assist the visual comparison.

A variation on this theme arises when you want each facet of a plot to display data from a single group, with the complete data set plotted unobtrusively in each panel to aid visual comparison.
The gghighlight package is particularly useful in this context:
Expand Down