map_data("world") |>
ggplot(aes(long, lat, group = group)) +
geom_polygon(fill = "white", color = "black") +
annotate("text", x = 0, y = 0, label = "Center", size = 10, color = "red")
Data Visualisation with R
annotate()
allows you to add elements to plots without a data.frame
geom_text()
or geom_label()
to add text to a plotggrepel
ggrepel
package to avoid overlapping textlibrary(ggrepel)
ChickWeight |>
filter(Chick %in% unique(Chick)[1:5], .by = Diet) |>
ggplot(aes(x = Time, y = weight)) +
geom_line(aes(group = Chick)) +
geom_text_repel(aes(label = paste("Chick", Chick)), nudge_x = 1,
data = ~filter(., Time == max(Time), .by = Chick),
color = "red") +
facet_wrap(~Diet, labeller = label_both)