banner



How To Change Axis Label Is Loop R


You tin can employ 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 10-axis interval              centrality(side=1, at=c(1, 5, 10, 15))              #specify y-axis interval              axis(side=2, at=seq(1, 100, by=x))                      

The following examples show how to utilize this syntax in do.

Example one: Specify Axis Intervals Using Private Values

The following code shows how to modify the 10-axis and y-axis intervals in a plot in base R using the c() function:

                                                            #define data                  x <- c(1, 2, three, 4, 5, 6, seven, 8, 9, 10, 11, 12, 13, 14, fifteen) y <- c(1, three, three, 4, 6, vii, 8, 14, 17, fifteen, 14, 13, nineteen, 22, 25)                  #create scatterplot                  plot(ten, y, col='steelblue', pch=xix, xaxt='n', yaxt='n')                  #modify x-centrality and y-axis intervals                  axis(side=one, at=c(1, 5, 10, 15)) axis(side=two, at=c(one, 12.v, 25))                                                    

Notice that the merely values shown along the x-centrality and y-axis are the specific values that we specified.

Instance two: Specify Centrality Intervals Using a Sequence of Values

The following lawmaking shows how to modify the x-axis and y-axis intervals in a plot in base R using the seq() role:

                                                            #define data                  ten <- c(1, two, 3, iv, five, 6, 7, 8, 9, 10, 11, 12, 13, fourteen, 15) y <- c(1, 3, 3, 4, 6, seven, viii, fourteen, 17, xv, 14, 13, 19, 22, 25)                  #create scatterplot                  plot(ten, y, col='steelblue', pch=19, xaxt='n', yaxt='n')                  #modify 10-axis and y-axis intervals                  axis(side=ane, at=seq(5, fifteen, by=5)) axis(side=2, at=seq(0, 25, by=5))                                                    

Notice that the only values shown along the 10-axis and y-axis are the values nosotros specified using the seq() function.

Instance 3: Specify Axis Intervals Using a Range of Values

The following lawmaking shows how to modify the x-axis interval in a plot in base R using the : function:

                                                            #ascertain data                  x <- c(1, 2, 3, four, v, half-dozen, seven, eight, 9, 10, eleven, 12, 13, 14, xv) y <- c(1, 3, three, 4, 6, 7, 8, 14, 17, xv, 14, 13, nineteen, 22, 25)                  #create scatterplot                  plot(10, y, col='steelblue', pch=19, xaxt='n')                  #modify x-axis interval                  axis(side=1, at=1:15)                                                    

Notice that base of operations R automatically produced y-axis interval values and then used the range of x-centrality interval values that we specified.

Additional Resource

The following tutorials explain how to perform other common plotting operations in R:

How to Set Axis Limits in R
How to Change Axis Scales in R
How to Draw a Legend Exterior of a Plot in R

How To Change Axis Label Is Loop R,

Source: https://www.statology.org/r-plot-axis-interval/

Posted by: romerobeatee.blogspot.com

0 Response to "How To Change Axis Label Is Loop R"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel