- 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 exclude extra margin between points and the axes for a plot created by using ggplot2 in R?
- How to change the background color of a plot created by using plot function 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 create boxplot in base R without axes labels?
- How to X-axis labels to the top of the plot using ggplot2 in R?
- How to change the adjustment of the plot title using ggplot2 to align it above the Y-axis labels in R?
- How to plot the X-axis labels on the upper-side of the plot 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 orientation and font size of x-axis labels using ggplot2 in R?
- How to change the X-axis labels for boxplots created by using boxplot function in R?
- How to change the title of a graph to italic created by using plot function in R?
- How to create a bar graph using ggplot2 without horizontal gridlines and Y-axes labels in R?

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

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).

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 −

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

Advertisements