R specifying x-axis ticks for a line plot

我的未来我决定 提交于 2019-12-01 10:59:04

You will need to resort to the manual axis creation. This can be done by (1) disabling the automatic axis creation (with xaxt='n' in the call to plot) and (2) make a custom call to the axis function.

Here is how I would proceed:

y = c(227, 342, 121, 275, 354, 999, 221, 475, 867, 347, 541)
x = c(1, 5, 10, 15, 20, 25, 30 ,35, 40, 45, 50)
plot(x, y, "l", xaxt='n')
axis(1,at=c(10,30,40),labels=c("March", "June", "August"))

Resulting in the following plot:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!