Replace x axis with label on weekdays

I made a plot:

plot(tapply(G$capacity, G$day, mean),type="b", ylim=c(250,400), 
     xlim=c(0,7),main="Capacity ",xaxt = "n",  xlab="weekday", ylab ="Capacity")

      

and I would like to mark the scale with Monday, Tuesday, Wednesday, etc., not with numbers.

Is it possible?

+3


source to share


1 answer


Try adding an argument xaxt="n"

to plot command

and then:

 wd <- weekdays(Sys.Date()+2:8)
 axis(1, at=seq_along(wd), labels=wd, las=2)

      



If you really want the "weekday" x-axis label, you can prevent a conflict by setting xlab = "to yours plot

and manually setting the label with mtext

(see here )

+3


source







All Articles