简体   繁体   English

在格子图中的y轴上显示“0”标签

[英]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? 有没有一种方法可以获得格子y轴上下边界的标签? (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? 补充问题:我可以只设置ylim的上限并采用下限的默认值吗?

There is a lattice option called skip.boundary.labels . 有一个名为skip.boundary.labels的晶格选项。 From the documentation under ?lattice.options : ?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. 数字标量介于0和1之间。除非明确请求,否则不会绘制太接近限制的刻度标记。 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. skip.boundary.labels的默认值为0.02 ,这将防止在y轴的顶部和底部(以及x轴的最左侧和右侧)打印轴标签。

Change the value of skip.boundary.labels to 0 to print labels at axis extremes. skip.boundary.labels的值更改为0以在极值轴上打印标签。 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 : 或者,更好的是,仅使用参数lattice.options对您正在创建的绘图执行此操作:

xyplot(decrease ~ treatment, OrchardSprays, ylim = c(0, 200),
    lattice.options = modifyList(lattice.options(),
    list(skip.boundary.labels = 0)))

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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