I am trying to have the x-axis labels to be split into two lines. I would also like the labels to be rotated 45 degrees. How can I do this?
What I have so far:
N <- 10
dnow <- data.frame(x=1:N, y=runif(N), labels=paste("This is observation ",1:N))
with(dnow, plot(x,y, xaxt="n", xlab=""))
atn <- seq(1,N,3)
axis(1, at=atn, labels=labels[atn])
Here's one possibility with the ggplot2
package.
N <- 10
labs <- factor(1:N,labels=paste("This is \n observation",1:N))
dnow <- data.frame(x=1:N, y=runif(N), labels=labs)
qplot(labels,y,data=dnow) +
opts(axis.text.x=theme_text(angle=-45,hjust=0))
I'm looking forward to seeing the base package examples, too!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With