How to determine which graph () indicates the x axis?

I have plot () which I am trying to do, but I do not want the x values ​​to be used as axis labels ... I need another character vector that I want to use as labels in the standard way: use as much as you like , drop the rest, etc. What should I pass to plot () for this to happen?

For example, consider

d <- data.frame(x=1:5,y=10:15,x.names=c('a','b','c','d','e')) 

In barplot, I would go through barplot(height=d$y,names.arg=d$x.names) , but in this case the important values ​​of x are important. Therefore, I need an analogue, for example, plot(x=d$x,y=d$y,type='l',names.arg=d$x.names) , but this does not work.

+19
r plot
Sep 08 '09 at 18:35
source share
1 answer

I think you want to first suppress the labels on the x axis using the xaxt = "n" option:

 plot(flow~factor(month),xlab="Month",ylab="Total Flow per Month",ylim=c(0,55000), xaxt="n") 

then use the axis command to add your own labels. This example assumes the labels are in an object named month.name

 axis(1, at=1:12, labels=month.name) 

I needed to see how to do this, and I stole an example here .

+47
08 Sep '09 at 18:43
source share



All Articles