Re: [R] trying to rotate barplot labels

From: Chuck Cleland <>
Date: Wed 18 Oct 2006 - 21:41:46 GMT

Leeds, Mark (IED) wrote:
> hi everyone : i'm trying to rotate the x axis labels in my barlot ( yes,
> since yesterday ) and my prob12matrix is 2 rows and 16 columns and i
> followed the instructions in the
> archive "rotate barplot labels". i was really looking forward to seeing
> my labels turned but the plot just came back with no labels ? can anyone
> see what might be going on ?
> it worked when i followed the archive using the simulated rnorm data
> generrated there.
> i've changed the naming method so that i'm using the labels command
> instead of the defaulted column names , so i wouldn't even mind getting
> them on unrotated because they
> might even fit now. if someone knows how to do that wqihout rotating,
> that;s worth a try
> maybe it has something do with that the rnorm data in the archive was
> ten values whereas i have 16 values ( or 32 if i do besides = T ) ? I
> don't
> know in depth what's really happening with all of these commands so it
> could be something with 10 versus 16. the plot looks fine though except
> for the lack of labels. also, if i take out axisnames=FALSE, it puts the
> columnnames on which don't fit. thanks a lot.
> par(mar=c(7,4,4,2) + 0.1)
> mp<-barplot(prob12matrix,axisnames=FALSE)
> axis(1,at= mp,labels=FALSE)
> labels<-c("+","+|+","+|++","+|-+","+|+++","+|-++","+|+-+","+|++-","+|+++
> +","+|-+++","+|+-++","+|++-+","+|+++-","+|--++","+|-+-+","+|-++-")
> text(mp,par("usr")[3]-0.5,srt=45,adj=1,labels=labels,xpd=TRUE)

  It could be that -0.5 is too big of a shift in the text. Here is an example where -0.5 does not work but -0.05 is just about right:

prob12matrix <- matrix(runif(32), ncol=16)

par(mar=c(7,4,4,2) + 0.1)

mp<-barplot(prob12matrix, axisnames=FALSE)

axis(1, at=mp, labels=FALSE)

labels<-c("+","+|+","+|++","+|-+","+|+++","+|-++","+|+-+","+|++-","+|+++ +","+|-+++","+|+-++","+|++-+","+|+++-","+|--++","+|-+-+","+|-++-")

text(mp, par("usr")[3]-0.05, srt=45, adj=1, labels=labels, xpd=TRUE)

  You need to experiment with how far down to shift the text from par("usr")[3].

hope this helps,


> --------------------------------------------------------
> This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received vi
a !
> e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive these communications. In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules).
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.

Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Oct 19 07:54:47 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 18 Oct 2006 - 22:30:11 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.