当我为R中的绘图设置限制时,我设置的限制与绘图区域的实际限制之间存在一定距离:
plot(c(1, 4), c(1, 4), ylim = c(1, 4))
当然,我可以在最外面的刻度中设置限制,使它们看起来接近绘图区域的边缘。通过单独绘制轴并允许它绘制在绘图区域之外,我可以非常接近:
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))
但这只是眼球。所以:
如何让最外面的刻度线在绘图区域的边框上完全?
答案 0 :(得分:4)
xaxs = 'i'
和yaxs = 'i'
将使它分别适合x和y轴的数据(details)。
答案 1 :(得分:2)
情节参数xaxs
和yaxs
有助于此:
plot(c(1, 4), c(1, 4), xaxs="i")