Re: [R] barplots and missing xlabels

From: Geoff Russell <geoffrey.russell_at_gmail.com>
Date: Mon, 14 Jan 2008 19:53:41 +1030

See below

On 1/14/08, Jim Lemon <jim_at_bitwrit.com.au> wrote:
> Geoff Russell wrote:
> > Dear useRs,
> >
> > The following plots only print 2 of the 4 labels under the bars, is there
> > a way please to force all 4 labels to print?
> >
> > par(mfrow=c(1,2),mar=c(2,7,3,1))
> > dat<-data.frame("AgeGroup"=c("2-15","16-20","21-25","26-39"),
> > "Aorta"=c(20,8,30,60),
> > "Coronary"=c(7,30,55,65))
> > barplot(dat$Aorta,ylim=c(0,100),names=as.vector(dat$AgeGroup),ylab=c("Prevalence
> > (%)"))
> > title(main=list("Aorta",font=0))
> > barplot(dat$Coro,names=as.vector(dat$Age),ylim=c(0,100))
> > title(main=list("Coronary Artery",font=0))
> >
> Hi Geoff,
>
> Try this:
>
> barplot(dat$Aorta,ylim=c(0,100),
> names=rep("",length(dat$AgeGroup)),
> ylab=c("Prevalence (%)"))
> mtext(dat$AgeGroup,1,2)

Thanks, but this puts all the labels overlaying each other in the 2nd line on the bottom of the plot. But

mtext(as.vector(dat$AgeGroup),1,at=c(1,2,3,4))

sort of works and if I play with the "at" argument I could make it work, but I'm sure there must be a better way.

Geoff.

>
> Jim
>

-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069

______________________________________________
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.
Received on Mon 14 Jan 2008 - 09:28:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jan 2008 - 09:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive