简体   繁体   English

使用plot()在x轴上显示更精细的值

[英]Showing finer values on the x-axis using plot()

I have two vectors: x and y. 我有两个向量:x和y。 I'm plotting them with plot(x,y, type="l"). 我用plot(x,y,type =“ l”)绘制它们。 However I want to show the detailed values on the x-axis between the plotted values on the x-axis. 但是,我想在x轴上的绘制值之间显示x轴上的详细值。 Now I have 0 ... 20 ... 40 ... I want to show 0 1 2 3 4 5 6 ... 20 and I want them to be in smaller size than the main values. 现在我有0 ... 20 ... 40 ...我想显示0 1 2 3 4 5 6 ... 20,我希望它们的大小小于主值。 How can I do that? 我怎样才能做到这一点?

在此处输入图片说明

Here is the answer to your question 这是您问题的答案

grid = 1:100

x = rnorm(100)
plot(x,type='l')
axis(1,grid[c(-20,-40,-60,-80,-100)],grid[c(-20,-40,-60,-80,-100)],cex.axis=.5,line=-1,tick=FALSE)

在此处输入图片说明

Use axis to customize it. 使用axis进行自定义。 For example: 例如:

plot(seq(1,100,10), rnorm(10),type='l',cex.axis=2,
     lwd.ticks=5)
axis(1, 1:100[-c(20,40,60,80,100)],
     1:100[-c(20,40,60,80,100)],tick=TRUE,
     cex.axis=0.8)

在此处输入图片说明

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

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