更新时间:2023-09-23 17:21:04
To add text to ggplot
, use geom_text
:
Method 1: Add a column of labels to your data.frame
:
tmp$note <- LETTERS[1:7]
ggplot(tmp,aes(date, price, label=note)) +
geom_line() +
geom_text(vjust=0, colour="red")
Method 2: Add a specific label:
ggplot(tmp,aes(date, price, label=date)) +
geom_line() +
geom_text(data=tmp[3, ], label="Something of note", vjust=1)