17

我正在绘制一些数据的 cdf,并且在“x”轴上添加了对数刻度。刻度间距正是我想要的,但我希望能够在特定点上添加 一些刻度线。

我不想改变我的情节中刻度线的分布,从n by nm by m,我只想在来自 的刻度线中n by n,在某些值上添加一些刻度线。

我想让它同时反映在轴xy轴上,这样我就可以在整个图表中将网格放入这些新标记中。

到目前为止,我有图表和网格——我不介意在图表后面或上面放置网格,我只想添加一些自定义刻度。

# Cumulative Distribuition
pdf("g1_3.pdf")

plot(x = f$V2, y = cumsum(f$V1), log = "x", pch = 3,
     xlab = "Frequency", ylab = "P(X <= x)",
     panel.first = grid(equilogs = FALSE))

axis(1, at = c(40, 150))
abline(h = 0.6, v = 40, col = "lightgray", lty = 3)
abline(h = 0.6, v = 150, col = "lightgray", lty = 3)

dev.off()

更新:我到目前为止的图表:

在此处输入图像描述

4

1 回答 1

19

考虑到初始脚本和@BenBolker 给出的提示,我不得不使用:

axis(side = 1, at = c([all the ticks you want]))

为了ticks在图中添加。这是最终结果:

# Cumulative Distribuition
pdf("g1_3.pdf")

plot(x = f$V2, y = cumsum(f$V1), log = "x", pch = 3,
     xlab = "Frequency", ylab = "P(X <= x)", axes = FALSE)

ticks = c(1, 5, 10, 40, 150, 500, 1000)
axis(side = 1, at = ticks)
axis(side = 2)

abline(h = seq(0, 1, 0.2), v = ticks, col = "lightgray", lty = 3)
box()

我试图生成的图表的最终结果

于 2012-12-24T04:22:22.970 回答