How to Modify the Space Between Axis Tick Marks of a Plot in Base R (2 Examples)

In this tutorial you’ll learn how to modify the space between axis ticks of a Base R plot in R programming.

Creation of Example Data

set.seed(34756)                      # Example data
x <- rnorm(1000)
y <- rnorm(1000) + 0.5 * x
plot(x, y)                           # Basic R plot

r graph figure 1 how modify space between axis tick marks a base r

Example 1: Manually Modify Positions of Axis Tick Marks Based On axis() Function

plot(x, y,                           # Apply plot function
     xaxt = "n",
     yaxt = "n")
axis(side = 1, at = c(- 1, 0, 1))    # Apply axis function to x-axis
axis(side = 2, at = 1:3)             # Apply axis function to y-axis

r graph figure 2 how modify space between axis tick marks a base r

Example 2: Manually Modify Positions of Axis Tick Marks Based On xaxp & yaxp

plot(x, y,                           # Plot data with axes specified by xaxp & yaxp
     xaxp = c(1, 100, 5),
     yaxp = c(1, 100, 9))

r graph figure 3 how modify space between axis tick marks a base r

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top