is there a comforable way to get labels for the upper and lower borders in the lattice y-axis? (without setting it concrete)
library(lattice)
xyplot(decrease ~ treatment, OrchardSprays, ylim=c(0,200))
supplementary question: can I set only the upper bound for ylim and take the default for the lower bound?
There is a lattice option called skip.boundary.labels
. From the documentation under ?lattice.options
:
skip.boundary.labels
Numeric scalar between 0 and 1. Tick marks that are too close to the limits are not drawn unless explicitly requested. The limits are contracted by this proportion, and anything outside is skipped.
The default value of skip.boundary.labels
is 0.02
, which will prevent axis labels at the very top and bottom of the y-axis (and at the very left and right of the x-axis) from being printed.
Change the value of skip.boundary.labels
to 0
to print labels at axis extremes. You can do this globally using
lattice.options(skip.boundary.labels = 0)
Or, better yet, do it only for the plot you are creating, using the argument lattice.options
:
xyplot(decrease ~ treatment, OrchardSprays, ylim = c(0, 200),
lattice.options = modifyList(lattice.options(),
list(skip.boundary.labels = 0)))