[R] No room for labels in barplot

David-Arnold david-arnold at Redwoods.edu
Thu Sep 6 20:03:10 CEST 2012


All,

I have:

sales <- c(2300,900,155,102,42,10)
names(sales) <- c("Christmas","Valentine's Day",
           "Mother's Day","Father's Day",
           "Thanksgiving","New Year's Day")
barplot(sales,ylim=c(0,2500))

But it doesn't place all of the name labels on the plot. So I tried:

sales <- c(2300,900,155,102,42,10)
names(sales) <- c("Christmas","Valentine's Day",
           "Mother's Day","Father's Day",
           "Thanksgiving","New Year's Day")
barplot(sales,ylim=c(0,2500),las=2)

But there wasn't enough room at the bottom margin for the labels. Then I tried:

sales <- c(2300,900,155,102,42,10)
names(sales) <- c("Christmas","Valentine's Day",
           "Mother's Day","Father's Day",
           "Thanksgiving","New Year's Day")
barplot(sales,horiz=TRUE,xlim=c(0,2500),las=1)

Still, not enough room in the margin for the labels. Now, I am going to be introducing students to barplots in R tonight and I'm looking for a simple way to fix this label problem without scaring them too much.

Any thoughts?

D.


More information about the R-help mailing list