r - 在点阵图中的 y 轴上显示 "0"标签

标签 r lattice axis-labels

有没有一种方便的方法来获取格子 y 轴上边界和下边界的标签? (没有设置具体)

library(lattice)

xyplot(decrease ~ treatment, OrchardSprays, ylim=c(0,200))

enter image description here

补充问题:是否可以只设置ylim的上限,下限取默认值?

最佳答案

有一个名为 skip.boundary.labels 的点阵选项。来自 ?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.

skip.boundary.labels 的默认值为 0.02,这将防止轴标 checkout 现在 y 轴的最顶部和最底部(以及最x 轴的左侧和右侧)以免被打印。

skip.boundary.labels 的值更改为 0 以在轴端打印标签。您可以使用

在全局范围内执行此操作
lattice.options(skip.boundary.labels = 0)

或者,更好的是,使用参数 lattice.options 只为您正在创建的绘图执行此操作:

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

enter image description here

关于r - 在点阵图中的 y 轴上显示 "0"标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27998363/

相关文章:

r - 使用方差分析测量回归系数贡献

r - 将字符添加到数据框列中每个元素的末尾

r - 如何根据 R 中的某个因素绘制一条稀疏(带间隙)线,其线段着色?

r - 如何在 Lattice 中更改绘图字符

r - 向格子条形图中的面板添加文本

python - 在一行中设置 x 和 y 标签

R Markdown 不同输出类型的不同 Echo 选项

r - 如何用R中的条件替换前两个匹配模式

python - 如何更改 Matplotlib 中刻度标签和轴标签之间的分隔

r - 用坐标轴和箭头绘制 R 中的函数