[R] histogram and boxplot in a same postscript

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Feb 16 15:50:03 CET 2005


Cézar Freitas wrote:

> Hi, all. I need plot a boxplot under a histogram like
> below, but some configs are troubled:
> 
> - the boxplot contours the plot, even if I put
> bty="n", modifying the histogram plot;

You want to set  "axes = FALSE" in boxplot()
BTW: What is q[4]  in your call to points()?


Uwe Ligges


> - I changed the configs of axis to do a 3x3 inches
> plot, but the result is 2 different axis.
> 
> For example, the code below ilustrates this...
> 
> 
>   scores<-c(2.0, 0.0, 5.0, 5.0, 5.0, 2.0, 0.0, 5.0,
> 2.5, 4.0, 5.0, 0.0, 5.0, 0.0, 2.0, 5.0, 5.0, 2.0, 3.0,
> 3.0)
> 
>   postscript("test.ps", width=3, height=3,
> horizontal=FALSE, family="Times", paper="special")
> 
>   gra<-hist(scores, breaks=((0:11)/2-.2),
> xlim=c(-1,6), plot=FALSE, cex.axis=.5, cex.main=.5,
> cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0))
> 
>   yy<-ceiling(max(gra$counts)/10)*10
>   
>   hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6),
> ylim=c(0,yy), main="scores", ylab="Freq", xlab="math",
> cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5,
> mgp=c(1.5,.5,0))
>   boxplot(scores, horizontal=1, add=1, at=-yy/50,
> boxwex=yy/20, bty="n", cex.axis=.5, cex.main=.5,
> cex.sub=.5, cex.lab=.5, ann=FALSE)
>   points(q[4], -yy/50, col=1, pch="x", cex=.2)
> 
>   dev.off()
> 
> 
> Thanks,
> C.
> 
> ______________________________________________
> 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




More information about the R-help mailing list