- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to change the starting and ending points of axes labels using plot function in R?

When we create a plot using plot function, the axes labels are automatically created based on the values of the variables that is being plotted. It is possible to set a limit to the labels for both the axes, X-axis and Y-axis and we can do this by using xlim and ylim options. For example, if we have the variable limits from 0 to 50 for variable that is going to be plotted on X-axis then it can be done as xlim = c(0,50).

## Example

set.seed(99) x <-sample(1:50,10) y <-sample(1:500,10)

Creating a plot between x and y −

plot(x,y)

Creating a plot between x and y by specifying the axes labels −

## Example

plot(x,y,xlim=c(0,50),ylim=c(0,500))

## Output

- Related Questions & Answers
- How to change the axes labels using plot function in R?
- How to change the color and size of the axes labels of a plot created by using plot function in R?
- How to display axes ticks and labels inside the plot using ggplot2 in R?
- How to extract axes labels for the plot drawn using ggplot2 in R?
- How to remove the plot margin in base R between the axes and the points inside the plot?
- How to remove starting and ending zeros in an R vector?
- How to change the background color of a plot created by using plot function in R?
- How to exclude extra margin between points and the axes for a plot created by using ggplot2 in R?
- How to change the position of the title of a plot which is created using plot function in R?
- How to change number formatting from scientific to numbers of axes labels in a scatterplot using ggplot2 package in R?
- How to add a straight line to a plot in R starting from bottom left and ending at top right?
- How to change the adjustment of the plot title using ggplot2 to align it above the Y-axis labels in R?
- Plot scatter points on 3d plot without axes and grids in Matplotlib
- How to X-axis labels to the top of the plot using ggplot2 in R?
- Create a ggplot2 graph without axes labels, axes titles and ticks in R.

Advertisements