我有一个我正在尝试制作的plot(),但我不希望将x值用作轴标签...我想要一个不同的字符向量,我想用作标签,在标准中方式:使用尽可能多的数量,丢弃其他数据等.我应该通过plot()来实现这一目标?
例如,考虑一下
d <- data.frame(x=1:5,y=10:15,x.names=c('a','b','c','d','e'))
Run Code Online (Sandbox Code Playgroud)
在barplot中,我会通过barplot(height=d$y,names.arg=d$x.names),但在这种情况下,实际的x值很重要.所以我想要一个类似的模拟plot(x=d$x,y=d$y,type='l',names.arg=d$x.names),但这不起作用.
JD *_*ong 48
I think you want to first suppress the labels on the x axis with the xaxt="n" option:
plot(flow~factor(month),xlab="Month",ylab="Total Flow per Month",ylim=c(0,55000), xaxt="n")
Run Code Online (Sandbox Code Playgroud)
then use the axis command to add in your own labels. This example assumes the labels are in an object called month.name
axis(1, at=1:12, labels=month.name)
Run Code Online (Sandbox Code Playgroud)
I had to look up how to do this and I stole the example from here.