[R] BarPlot

David Barron mothsailor at googlemail.com
Sun Oct 15 23:23:29 CEST 2006


Try adding

> text(31,3.8,expression(paste(alpha==5,"%")),pos=3)


On 15/10/06, Mohsen Jafarikia <jafarikia at gmail.com> wrote:
> Hello again,
>
> Thanks for answering my questions.
> If my program is now:
>
>  pdf('Test.pdf')
> BL<-c(1.97,8.04,2.54,10.53,4.85,1.73)
> LR<-c(0.85,0.86,8.33,04.18,6.26,2.40)
>  Q<-c(0.00,0.00,1.92,01.92,4.48,0.00)
>
>  cols <- ifelse(Q!=0, "orange", "green")
> Graph<- barplot(LR, main='LR Value',col=cols, border='black', space=0.05,
> width=(BL), xlab='Length', ylab='LR block')
>
> axis(1, at=Graph, sprintf('%0.2f',BL))
> mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ""), line=2)
> mtext(1, at=par('usr')[1], text='BL', line=1)
> mtext(1, at=par('usr')[1], text='Var', line=2)
> abline(h=3.8, col='blue')   <<<<<<<<<< I want to add "alpha=5%" at the end
> of this line
>
>  And now I want to write "alpha=5%" at the end of the line that I have on my
> graph.
>
> Thanks,
> Mohsen
>
>
>
> On 10/15/06, Marc Schwartz <MSchwartz at mn.rr.com> wrote:
> >
> > On Sat, 2006-10-14 at 23:52 -0400, Mohsen Jafarikia wrote:
> > > Hello everyone,
> > >
> > > I have the following program to draw a barplot.
> > >
> > >
> > >
> > > MP<-read.table(file='AR.out')
> > >
> > > names(MP)<-c('BN','BL','LR','Q')
> > >
> > > Graph<- barplot(MP$LR, main='LR Value', col='orange', border='black',
> > space=
> > > 0.05, width=(MP$BL), xlab='Length', ylab='LR each')
> > >
> > > axis(1, at=Graph, sprintf('%0.2f',MP$BL))
> > >
> > > mtext(1, at=Graph, text=sprintf('%0.2f',MP$Q), line=2)
> > >
> > > mtext(1, at=par('usr')[1], text='BL', line=1)
> > >
> > > mtext(1, at=par('usr')[1], text='Var', line=2)
> > >
> > > abline(h= 3.841,col='blue')
> > >
> > > abline(h=6.635,col='red')
> > >
> > >
> > >
> > > I have two more questions about the graph that I have:
> > >
> > > 1) I want to write the 'Q' only when it is not equal to zero.
> > >
> > > 2) I would like to change the bars when 'Q' is not zero. For example,
> > from
> > > orange to green.
> > >
> > >
> > >
> > > I would appreciate your input to this question.
> > > Thanks,
> > >
> > > Mohsen
> >
> > It would be helpful to have the data that you are working with so that
> > we can provide each other a working example.
> >
> > However, here are some hints:
> >
> > 1.
> >
> >   mtext(1, at = Graph,
> >         text = ifelse(MP$Q != 0, sprintf('%0.2f',MP$Q), ""),
> >         line=2)
> >
> >
> > 2.
> >
> >   cols <- ifelse(MP$Q != 0, "orange", "green")
> >   barplot(..., col = cols, ...)
> >
> >
> > See ?ifelse
> >
> > HTH,
> >
> > Marc Schwartz
> >
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP



More information about the R-help mailing list