The text() function is used to add text to plot in R.

The following method shows how you can do it with syntax.

Method 1: Use text() Function

text(x=x, y=y, labels="Text")

The following example shows how to use text() function in R to add text to plot.

Using text() Function

Let’s see how to use text() function in R:

# Create dataframe
df <- data.frame(Machine_name=c("A","B","C","D","E","F","G","H"),

# Create scatterplot

# Add text in plot
text(x=20,y=35,"This is scatter plot")


Here the above snippet shows scatter chart along with text added to it.