How to add text to individual curves on a plot in R?

r
datavisualization
plot

#1

Hello,

I want to add some text or labels on different curves on the same plot, How to do it in R?

I want something like this->

Thanks.


#2

The text() function allows us to put text on the plot where we want it. An obvious use is to label a line or group of points.
text(c(2,2),c(37,35),labels=c(“Non-case”,“Case”))

This would give us two labels in the upper right corner of the plot, which with appropriate arrows could be used in place of a legend. Note that vectors were supplied as the coordinates. The first label would be centered at (2,37), and the second at (2,35), as the default alignment is to center the labels.