# How to put labels on a scatterplot that is created plot function in R?

R ProgrammingServer Side ProgrammingProgramming

Labelling of points on a scatterplot helps us to identify the pair of observations. For example, if we are plotting weight and height of people then we can label it with person’s name, therefore, we will be able to understand which pair of points belong to which person. This can be done by using text function after creating the scatterplot with plot function.

## Example

x <-c(2,4,5,8,10)
y <-c(15,25,27,29,30)
plot(x,y)

## Output

Now suppose we have labels and want to add them on the above plot then it can be done as follows −

Labels <-c("One","Two","Three","Four","Five")
text(x,y,labels=Labels,cex=0.4,pos=3)

## Output

Published on 21-Aug-2020 12:23:12