[R] histogram and boxplot in a same postscript
Cézar Freitas
cafanselmo12 at yahoo.com.br
Wed Feb 16 14:11:54 CET 2005
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;
- 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.
More information about the R-help
mailing list