Skip to content

Behavior of ylim in boxplot() when horizontal=TRUE

1 message · Wolfgang Viechtbauer

#
Hi all,

I just noticed something when using boxplot(). Say we have this boxplot:

boxplot(mpg ~ cyl, data=mtcars, xlab="Cylinders", ylab="Miles per Galon", ylim=c(10,40), log="y")

ylab, ylim, and log="y" are all consistently adjusting things on the y-axis (the numeric 'outcome' variable).

Now let's use horizontal=TRUE:

boxplot(mpg ~ cyl, data=mtcars, las=1, xlab="Miles per Galon", ylab="Cylinders", horizontal=TRUE, ylim=c(10,40), log="x")

Now xlab and log="x" are used to adjust things on the x-axis, but ylim still needs to be used to adjust the range of the numeric 'outcome' variable. Not a big deal, but this seems a bit inconsistent.

Best,
Wolfgang