R plot() – Set X, Y Axes Labels

To set labels for X and Y axes in R plot, call plot() function and along with the data to be plot, pass required string values for the X and Y axes labels to the “xlab” and “ylab” parameters respectively.

By default X-axis label is set to “x”, and Y-axis label is set to “y”. We override these values using xlab and ylab parameters of plot() function.

In this tutorial, we will learn how to set labels for X and Y axes, with example programs.


The syntax to set labels for X, Y axes using plot() function is

plot(x, y, xlab="X Label", ylab="Y Label")


In the following program, we will take plot a graph, and set it its X-label to “Time”, and Y-label to “Magnitude”.


x <- seq(0, 10, 0.5)
y <- sin(x)
plot(x, y, xlab="Time", ylab="Magnitude")


R Plot - Set X, Y axes labels


In this R Tutorial, we learned how to set X and Y axes labels for plot using “xlab” and “ylab” parameters of plot() function respectively, with the help of example program.