gpt4 book ai didi

r - 如何将绘图区域裁剪到 R 中数据的确切范围?

转载 作者:行者123 更新时间:2023-12-02 08:35:23 25 4
gpt4 key购买 nike

当我在 R 中为绘图设置限制时,我设置的限制与绘图区域的实际限制之间存在一些距离:

plot(c(1, 4), c(1, 4), ylim = c(1, 4))

enter image description here

当然,我可以在最外面的刻度内设置限制,这样它们看起来就落在绘图区域的边缘附近。我可以通过单独绘制轴并允许它在绘图区域之外绘制来非常接近:

plot(c(1, 4), c(1, 4), ylim = c(1.2, 3.8), axes = FALSE)
par(xpd = TRUE)
abline(h = 4, col = "grey") # just to show the edge of the box
axis(2, at=c(1, 4), labels = c(1, 4))

enter image description here

但这只是目测而已。所以:

如何让最外面的刻度线恰好落在绘图区域的边界上?

最佳答案

绘图语句中的

xaxs = 'i'yaxs = 'i' 将使其分别精确地适合 x 轴和 y 轴的数据 (details) .

关于r - 如何将绘图区域裁剪到 R 中数据的确切范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22158002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com