[R] BarPlot

David Barron mothsailor at googlemail.com
Mon Oct 16 23:06:27 CEST 2006


Specify margins using par(mar=c(5,1,4,2)) before the call to barplot.
You won't be able to see the vertical axis labels with those settings,
though.

On 16/10/06, Mohsen Jafarikia <jafarikia at gmail.com> wrote:
> Hello everyone:
>
> I am using the following code to draw my barplot but it has two problems.
>
> 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',mar=c(5,1,4,2))  <<<<<<<<<
> 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.84,col='blue')
> abline(h=6.64,col='red')
> text(31,3.84,expression(paste(alpha==5,"%")),pos=3)    <<<<<
> text(31,6.64,expression(paste(alpha==1,"%")),pos=3)    <<<<<
>
> 1)      I don't know how to specify the margins. I have written it in the
> code but it is not working.
> 2)      I want the value of alph=5% at the right end of the line but it is
> almost in the left side and sometimes in the right side when I use the same
> code for drawing another barplot.
>
> I appreciate any comments about these problems.
>
> Thanks,
> Mohsen
>
>         [[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