向下移动并保留 r 中绘图的所有放大轴编号标签

Moving down and keeping all enlarged axis number labellings of a plot in r

我有一个对数刻度的图:

png("test.png")
set.seed(20)
x = 1:100
y = sample(100)
plot(x,y,log="x",xaxt='n',cex.axis=2)
axis(1,cex.axis=4)
dev.off()

test.png 产量:

我想要两样东西,

  1. 向下移动轴编号,使它们不与轴重叠并且它是刻度线
  2. 保留消失的数字“2”、“10”、“50”,即使它们与其他数字重叠。 (轴号不能变小!)

谢谢。

是这样的吗?我们可以使用 mapply(),它为 axTicks() 返回的每个刻度位置调用一次 axis()。这样做可以让您保留未显示的缺失值,以避免过度绘制。另外,我用 padj 填充了一些内容,这样您的值就不会进入情节本身。

png("test.png")
set.seed(20)
x = 1:100
y = sample(100)


plot(x,y,log="x",xaxt='n',cex.axis=2)
mapply(axis, 
       side = 1, 
       at = axTicks(1), 
       labels = axTicks(1), 
       cex.lab=4, 
       cex.axis=4, 
       cex.main=4, 
       cex.sub=4, 
       padj = 0.5)