使用 axis() 绘制不带刻度的轴

Use axis() to draw axis without ticks

给定一个没有轴的图,我想使用 axis 添加一个水平轴。在左侧,您会看到给定的 "baseline" 图,在右侧,您会看到所需的结果:

基线图是使用

简单生成的
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

我希望最后一张图能够提供所需的输出,但轴根本没有画出来。显然,ticks = FALSE 也会抑制轴本身。

备注:"expected" 图是使用

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

但我正在寻找一种 "cleaner" 解决方案,而不是将不需要的标记放在可见区域之外。

这似乎是你想要的情节:

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

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

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