简体   繁体   English

如何在R中的x轴上设置离散值

[英]How to set discrete values in x-axis in R

When I plot data: 当我绘制数据时:

plot(c(1.2,4,7),col=2)

How do I display my graph so it only shows whole values on the x axis? 如何显示图形,使其仅在x轴上显示整个值?

First turn off the x-axis in your plot statement: 首先在plot语句中关闭x轴:

plot(c(1.2, 4, 7), col=2, xaxt="n")

Then add the axis of your choice, for example: 然后添加您选择的轴,例如:

axis(1, at=round(x, 0))

where x is the unrounded values at where you would like tick marks 其中x是您想要刻度线的未取整值

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

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