Change Spacing of Axis Tick Marks in Base R Plot
In this article, we are going to see how to modify the space between axis tick marks of a Base R plot in R programming.
It can be done in the following ways:
- Using xaxp & yaxp method.
- Using axis() Function.
Method 1: Using xaxp & yaxp method
The first tick mark, last tick, and a number of tick mark parameters are given represented by a,b,c shown in the below syntax. These parameters are put into used to change in spacing between axis ticks in the base plot.
Syntax: plot(x, y, xaxp = c(a,b,c), yaxp = c(a,b,c))
- a= first tick mark
- b= last tick mark
- c= Number of tick marks
Method 2: Using axis function.
In this method, first, there is a need to create a plot without axis ticks. Then, add ticks by applying the axis() function. Different ticks are added in the way as represented by a, b, c parameters in syntax. So, this is one such method to change the spacing between axis ticks in Base R Plot.
plot(x, y, xaxt = “n”,yaxt = “n”)
axis(side = 1, at = c(a, b, c….))
axis(side = 2, at = c(a, b, c…..))
a, b, c = values of axis ticks