[R] Adjust barplot to the left

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Tue Sep 25 13:55:38 CEST 2007


barplot(height,width,xlim=c(-1,4), space=c(-.5,1.5,1.5))
will do the trick.

"space" is a relative parameter depending on "width" so you get 
1.5*0.4=0.6 space and with width=0.4 you get an overall distance of 1 
between to bars.

hth.

squall44 schrieb:
> Hello,
>
> I have the following problem: I created an ecdf and a barplot. Unfortunatly,
> the bars are not where I would like them to be (please see picture below).
>
> http://www.nabble.com/file/p12877530/problem.gif 
>
> That's my code:
> #------------------------
> par(mfrow=c(2,1), mar=c(2,3,3,2))
>
> #ECDF
> x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2)
> F2.5 <- ecdf(x)
> plot(F2.5,
>   verticals= TRUE,
>   do.p = TRUE,
>   lwd=3,
>   ylab = "",
>   xlab = "",
>   main = "Figur 2.12 Frequenztabelle und eVf",
>   xlim = c(-1,4))
> abline(h= (0:10)*0.1)
> mtext(text="x", side=1, adj = 1.03, padj=1.23, cex=1.2)
> mtext(text="f(x)", side=3, adj = -0.06, padj=-1, cex=1.2)
>
> par(mar=c(4,3,1,2))
>
> #Barplot               
> width<-c(0.4, 0.4, 0.4)
> height<-c(0.5, 0.35, 0.15)
> barplot(height,width,xlim=c(-1,4), space=1.5,)
> axis(side=1)
> #------------------------
>
> Can anyone tell me how I can adjust the bars to the left?
> Thanks
>
> Tobias
>   


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790



More information about the R-help mailing list