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>
How to draw a border for multiple graphs in one pager
2 messages · Lu Wang, Jim Lemon
On 01/30/2010 02:22 AM, Lu Wang wrote:
... 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().
Try using box only on the second and third plot: pie(value,labels=lbls,col=colors,radius=0.5) pie(value,labels=lbls,col=colors,radius=0.5) box(which="figure",type="l") pie(value,labels=lbls,col=colors,radius=0.5) box(which="figure",type="7") pie(value,labels=lbls,col=colors,radius=0.5)
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 think if you want left-aligned labels and right-aligned percentages, you will have to do the best you can with different numbers of spaces between the labels and percentages. Jim