简体   繁体   中英

show “0” label on y-axis in lattice plot

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)))

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM