How to Set Origin of Plot Axes to Zero in R (Example Code)

In this tutorial you’ll learn how to set the start of x- and y-axes to zero in the R programming language.

Example: Set Plot Axes to Start at 0

plot(10:20, 10:20,        # Create plot with default axes
     pch = 16, cex = 3)

r graph figure 1 set origin axes zero

plot(10:20, 10:20,        # Force origin of axes to start at zero
     pch = 16, cex = 3,
     xlim = c(0, 20), 
     ylim = c(0, 20),
     xaxs = "i",
     yaxs = "i")

r graph figure 2 set origin axes zero

Related Articles & Further Resources

Have a look at the following R programming tutorials. They focus on topics such as ggplot2 and graphics in 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