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
@@ -45,9 +43,7 @@ However, this makes the code difficult to reuse as values are hard coded and not
45
43
46
44
One way to automate this is to create a supplementary data frame with desired co-ordinates of the labels (see `ann_labs` in the example below). `nudge` arguments can be used to displace text to improve the positioning.
47
45
48
-
```{r annotations-2}
49
-
#| fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."
50
-
46
+
```{r annotations-2, fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."}
51
47
ann_labs <- ann_data |>
52
48
group_by(country) |>
53
49
filter(year == max(year)) |>
@@ -80,9 +76,7 @@ ann_data |>
80
76
81
77
Annotations may also be used to add value labels to a bar chart. Note that `geom_text()` is used here as a background is not required.
82
78
83
-
```{r annotations-3}
84
-
#| fig.alt = "A bar chart with white text labels at the end of each bar."
85
-
79
+
```{r annotations-3, fig.alt = "A bar chart with white text labels at the end of each bar."}
86
80
ggplot(bar_data, aes(x = reorder(country, -pop), y = pop)) +
0 commit comments