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"),
                 Temperature=c(12,9,14,13,18,28,22,23),
                 Pressure=c(20,25,27,29,30,32,39,40))

# Create scatterplot
plot(df$Temperature,df$Pressure)

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

Scatterplot

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