mwittmann at bren.ucsb.edu
2008-Apr-28 00:15 UTC
[R] Label Rotation when Plotting with Factors
Hello, Sorry if this is a repeat, having trouble finding what I need on archive and am a novice with graphics in R! I have plotted the results of a logit regression by factor, where "city" is the factor set name. The problem is city names are too long and I need to rotate them 90 degrees along the xaxis. This is what I've tried... plot(city, predicted.probability, xlab = "city"...) axis(1,las = 2) This does not affect the existing labels. I have also tried (axes=FALSE), and then rename new with (labels = "Denver", etc. ), but it seems as though I need to maintain the factor identities, as it give me the error: 'labels' is supplied and not 'at' Any suggestions? Thank you, marion wittmann
Is this what you want: city <- factor(c("denver", 'cincy', 'chicago','nyc')) par(mar=c(8,4,1,1)) # enough margin on x-axis plot(city, 1:4, xaxt='n') axis(1, at=as.numeric(city),labels=city, las=2) On Sun, Apr 27, 2008 at 8:15 PM, <mwittmann at bren.ucsb.edu> wrote:> Hello, > > Sorry if this is a repeat, having trouble finding what I need on archive and am > a novice with graphics in R! > > I have plotted the results of a logit regression by factor, where "city" is the > factor set name. The problem is city names are too long and I need to rotate > them 90 degrees along the xaxis. This is what I've tried... > > plot(city, predicted.probability, xlab = "city"...) > axis(1,las = 2) > > This does not affect the existing labels. > > I have also tried (axes=FALSE), and then rename new with (labels = "Denver", > etc. ), but it seems as though I need to maintain the factor identities, as it > give me the error: 'labels' is supplied and not 'at' > > Any suggestions? > > Thank you, > > marion wittmann > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?