Table of Contents
Changing the axis intervals in R plots allows for a more customized and accurate representation of data. By adjusting the intervals, the data can be displayed in a way that highlights important points or trends. This can be achieved by using the “axis” function in R, which allows for the manipulation of the axis parameters. For example, the “at” argument can be used to specify the exact points where tick marks should be placed on the axis. This can be particularly useful when dealing with large or complex datasets. Additionally, the “labels” argument can be used to assign custom labels to the axis intervals. Overall, changing the axis intervals in R plots offers a versatile tool for enhancing data visualization and making it more meaningful for interpretation. Some examples of this can be seen in various statistical and scientific studies, as well as in business and finance applications.
Change Axis Intervals in R Plots (With Examples)
You can use the following basic syntax to change axis intervals on a plot in base R:
#create plot with no axis intervals plot(x, y, xaxt='n', yaxt='n') #specifty x-axis interval axis(side=1, at=c(1, 5, 10, 15)) #specify y-axis interval axis(side=2, at=seq(1, 100, by=10))
The following examples show how to use this syntax in practice.
Example 1: Specify Axis Intervals Using Individual Values
The following code shows how to modify the x-axis and y-axis intervals in a plot in base R using the c() function:
#define data
x <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
y <- c(1, 3, 3, 4, 6, 7, 8, 14, 17, 15, 14, 13, 19, 22, 25)
#create scatterplot
plot(x, y, col='steelblue', pch=19, xaxt='n', yaxt='n')
#modify x-axis and y-axis intervals
axis(side=1, at=c(1, 5, 10, 15))
axis(side=2, at=c(1, 12.5, 25))

Notice that the only values shown along the x-axis and y-axis are the specific values that we specified.
Example 2: Specify Axis Intervals Using a Sequence of Values
The following code shows how to modify the x-axis and y-axis intervals in a plot in base R using the seq() function:
#define data
x <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
y <- c(1, 3, 3, 4, 6, 7, 8, 14, 17, 15, 14, 13, 19, 22, 25)
#create scatterplot
plot(x, y, col='steelblue', pch=19, xaxt='n', yaxt='n')
#modify x-axis and y-axis intervals
axis(side=1, at=seq(5, 15, by=5))
axis(side=2, at=seq(0, 25, by=5))

Notice that the only values shown along the x-axis and y-axis are the values we specified using the seq() function.
Example 3: Specify Axis Intervals Using a Range of Values
The following code shows how to modify the x-axis interval in a plot in base R using the : function:
#define data
x <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
y <- c(1, 3, 3, 4, 6, 7, 8, 14, 17, 15, 14, 13, 19, 22, 25)
#create scatterplot
plot(x, y, col='steelblue', pch=19, xaxt='n')
#modify x-axis interval
axis(side=1, at=1:15)

The following tutorials explain how to perform other common plotting operations in R:
Cite this article
stats writer (2024). How can I change the axis intervals in R plots? Can you provide some examples?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-change-the-axis-intervals-in-r-plots-can-you-provide-some-examples/
stats writer. "How can I change the axis intervals in R plots? Can you provide some examples?." PSYCHOLOGICAL SCALES, 12 May. 2024, https://scales.arabpsychology.com/stats/how-can-i-change-the-axis-intervals-in-r-plots-can-you-provide-some-examples/.
stats writer. "How can I change the axis intervals in R plots? Can you provide some examples?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-change-the-axis-intervals-in-r-plots-can-you-provide-some-examples/.
stats writer (2024) 'How can I change the axis intervals in R plots? Can you provide some examples?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-change-the-axis-intervals-in-r-plots-can-you-provide-some-examples/.
[1] stats writer, "How can I change the axis intervals in R plots? Can you provide some examples?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, May, 2024.
stats writer. How can I change the axis intervals in R plots? Can you provide some examples?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
