简体   繁体   English

独立于x值更改x轴标签

[英]Change x-axis labeling independent of x values

I have a problem with the x-axis labelling. 我对x轴标签有疑问。

I created a lm model(first.stage) and plotted the residuals using the code: 我创建了一个lm模型(first.stage),并使用以下代码绘制了残差:

plot(first.stage$residuals,ylab="Deviation",xlab="Year",type="l",col="blue")

Now I'd like to change the x-axis labelling independent from the x values. 现在,我想独立于x值更改x轴标签。

More precisely, I want to show the years 1960-2010 on the x axis. 更准确地说,我想在x轴上显示1960-2010年。 I tried a lot nothing worked. 我尝试了很多没有用的方法。

If you want to set custom tick marks for your x axis, set xaxt = 'n' in the plot() call, then use axis(1, at = c()) to set the new tick marks. 如果要为x轴设置自定义刻度线,请在plot()调用中设置xaxt = 'n' ,然后使用axis(1, at = c())设置新的刻度线。 For example, 例如,

plot(mtcars$wt, mtcars$mpg, xaxt='n')
axis(1, at = c(1.5, 2.5))

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

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