How to use xlim() and ylim() functions in base R In R Language
In this method of changing the axis intervals, the user needs to call the xlim() and ylim() functions, passing the arguments of the range of the axis intervals required by the user in form of the vector, this will be changing the axis intervals of the plot as per the specified parameters by the user in the R programming language.
xlim() and ylim() functions are used to limit the x-axis and the y-axis.
Syntax:
xlim(…)
ylim(…)
Parameters:
…: If numeric, will create a continuous scale, if factor or character, will create a discrete scale.
Syntax:
barplot(data,xlim=c(),ylim=c())
Example: Initial plot
R
gfg<- c (8,9,6,5,8,5,1,7,3,5) barplot (gfg) |
Output:
Example: Change axis intervals
R
gfg<- c (8,9,6,5,8,5,1,7,3,5) barplot (gfg,xlim= c (0,20), ylim= c (0,15)) |
Output:
How to Change Axis Intervals in R Plots?
In this article, we will be looking at the different approaches to change axis intervals in the R programming language.
Contact Us