When I do a boxplot diagram with the R boxplot
function, this function prints the y-axis automatically.
library(datasets)
boxplot(cars[c('speed', 'dist')],
col = "lightgray")
In the ?boxplot
I found the ylim
parameter that change the y-axis limits, but not change the scale. So I tried to use the axis
function to divide the scale from 0 to 120 every 10:
axis(4, at = seq(0, 120, 10))
. But I'm not getting a satisfactory result.
I can't see where I'm making mistakes. Could someone help with this question?
Thanks in advance.
library(datasets)
boxplot(cars[c('speed', 'dist')], col = "lightgray", ylim = range(0:120), yaxs = "i")
axis(4, at=seq(0, 120, 10))
The y-axis is on the right-hand side as you wanted I believe.