简体   繁体   English

如何:更改R中的x轴值?

[英]How to: change x-axis values in R?

I have a plot with two y-axes and the corresponding x values run from 1 to 18, in steps of 1. I want to change the x-axis with a scale ranging from 2 to 16 with steps of 1. When I'm trying to alter the scale, the right end of x-scale is empty after 16, as R automatically replaces the old values with the new ones and leaves the empty spaces at the right end open. 我有一个带有两个y轴的图,并且对应的x值从1到18,以1为步长。我想以2到16的范围,以1为步长来更改x轴。尝试更改刻度时,x刻度的右端在16之后为空,因为R会自动用新值替换旧值,并在右端保留空白。

par(mar=c(5, 4, 4, 6) + 0.1)
plot(section, c, pch=16, axes=FALSE, ylim=c(-22,-18), xlab=" ", ylab=" ", type="b", col="black", main="BG")
axis(2, ylim=c(-22,-18), col="black", las=1)
mtext(expression(paste(delta^{13}, "C (‰)")),side=2, line=2.5)
box()
par(new=TRUE)
plot(section, n, pch=15, xlab=" ", ylab=" ", ylim=c(10,13), axes=FALSE, type="b", col="red")
axis(4, ylim=c(10,13), col="red", col.axis="red", las=1)
mtext(expression(paste(delta^{15}, "N (‰)")), side=4, col="red", line=4)

axis(1, at=floor(seq(from=2.5, to=15.5, length.out=13)))
axis(1, pretty(range(section), 18))

These last two don't give me the result I'm looking for(can't post my image?). 最后两个没有给我我想要的结果(无法发布我的图像?)。

Any ideas on how to fix this? 有想法该怎么解决这个吗? I would very much appreciate it. 我非常感谢。

我认为您正在寻找xlim参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM