使用axis()绘制没有刻度的轴

时间:2015-04-22 19:49:23

标签: r plot axis

鉴于没有轴的情节,我想用axis添加水平轴。在左侧,您可以看到给定的"基线"在右侧绘制所需的结果: Baseline and expected plot

使用

简单生成基线图
plot(1, axes = FALSE, main = "Baseline")

问题:如何生成所需的输出? (条件:在生成图表后使用axis。)

我希望在指定tick = FALSE, labels = FALSE时能得到我想要的东西,但这不起作用。在我的测试之下,希望不言自明:

par(mfrow = c(2,2))

plot(1, axes = FALSE, main = "Full axis")
axis(1) # axis, ticks and labels

plot(1, axes = FALSE, main = "No labels")
axis(1, labels = FALSE) # axis, ticks

plot(1, axes = FALSE, main = "No ticks (and no axis)")
axis(1, tick = FALSE) # NO axis (unexpected), labels

plot(1, axes = FALSE, main = "Nothing (instead of axis)")
axis(1, tick = FALSE, labels = FALSE) # nothing - expected: only axis without ticks, without labels

Tests

我预计最后一个绘图会提供所需的输出,但根本不会绘制轴。显然,ticks = FALSE也会抑制轴本身。

备注:"预期"情节是使用

生成的
plot(1, axes = FALSE, main = "Expected")
axis(1, at = c(-100, 100))

但我正在寻找一个更清洁的"解决方案,而不是在可见区域外放置不需要的滴答。

2 个答案:

答案 0 :(得分:3)

其他解决方法是axis(1, lwd.tick=0, labels=FALSE)axis(1, tcl=0, labels=FALSE),分别绘制0宽度或0长度刻度。 @ LyzandeR的解决方案似乎在轴顶部绘制了白色刻度。建议的box()解决方案和?par似乎不仅仅绘制X轴?

答案 1 :(得分:0)

这似乎描绘了你想要的东西:

plot(1, axes = FALSE, main = "No labels")
axis(1, label=F, col.ticks='white') # axis, ticks

它只是将刻度打印为白色:

enter image description here

相关问题