我的例子:
x = c(1:15)
y = c(-4:10)
plot(x, y)
Run Code Online (Sandbox Code Playgroud)
R xlim
自动给出:2, 4, 6, ..., 14
我怎样才能改变它: 1, 2, 3,..., 15
我试过了 :
my.limits = as.numeric(seq(1, 15, by = 1))
x = c(1:15)
y = c(-4:10)
plot(x, y, ylim = c(-4,10), xlim = my.limits)
Run Code Online (Sandbox Code Playgroud)
但有错误:
Erreur dans plot.window(...) : valeur 'xlim' incorrecte
Run Code Online (Sandbox Code Playgroud)
你可以像这样手动设置滴答:
x=c(1:15)
y=c(-4:10)
plot(x,y, xaxt="n", xlim = c(1,15))
axis(1, at = 1:15)
Run Code Online (Sandbox Code Playgroud)
axt="n"
首先省略绘制x轴plot
.axis
之后手动绘制 - 你可以通过这种方式获得更多控制权.