[R] How to draw a border for multiple graphs in one pager

Lu Wang lueryy2000 at yahoo.com
Fri Jan 29 16:22:53 CET 2010


Hi,

I
am struggling to create a 2 by 2 multiple graphs in one page. I used
par(mfrow=c(2,2)) to divide the screen into 4. In each screen I draw a pie chart (They are all same). 

For example, my data is like this
Concentration                 value
A1                                 69
A2                                 8
G1                                 51
G2                                 1
G3                                 68   
G4                                 1
M                                  17

A1, A2... is different levels of the variable called concentration. Folllowing are their values. I uesd the R code below:
colors <- c("orange","red","purple","pink","blue","yellow","green")
lbls <- round(value/sum(value)*100,1)
lbls <- paste(lbls,"%",sep="")
postscript(file="H:/piechart.eps", height = 8, width = 8,onefile = FALSE, paper = "special")
par(mfrow=c(2,2),mar=c(0,0,0,0))
pie(value,labels=lbls,col=colors,radius=0.5)
box(bty="o",col = 'black')
leg <- paste(concentration,lbls,sep=", ")
legend(-1,0.85,leg,cex=0.8,fill=colors)

par(mfrow=c(2,2),mar=c(0,0,0,0))
pie(value,labels=lbls,col=colors,radius=0.5)
box(bty="o",col = 'black')
leg <- paste(concentration,lbls,sep=", ")
legend(-1,0.85,leg,cex=0.8,fill=colors)

par(mfrow=c(2,2),mar=c(0,0,0,0))
pie(value,labels=lbls,col=colors,radius=0.5)
box(bty="o",col = 'black')
leg <- paste(concentration,lbls,sep=", ")
legend(-1,0.85,leg,cex=0.8,fill=colors)

par(mfrow=c(2,2),mar=c(0,0,0,0))
pie(value,labels=lbls,col=colors,radius=0.5)
box(bty="o",col = 'black')
leg <- paste(concentration,lbls,sep=", ")
legend(-1,0.85,leg,cex=0.8,fill=colors)

dev.off()

My
question is How do I remove the outside frame. It seems that Box() can
only generate four sided boders. Or is there any way that I can draw
the inner border without using box(). 

Another question is how
can I align the text in the legend? You can see when I concatenate the
concentration level and the percentage, it looks unclear. Is it
possible that percentage can be right aligned? 

I am not sure if you can generate the same figure as mine using the above code, so I attached my graph in case you can't get it. Thank you very much.

John


      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: piechart.eps
Type: application/postscript
Size: 28639 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100129/73264ded/attachment.eps>


More information about the R-help mailing list