shift pie chart

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

shift pie chart

eimichae
Dear R-help members,
I did the following pie chart:

R:Code=

plants<-c(11,5,4,4,4,3,3,3,3,3,3,2,2,2,2,2,2,43)
pie(plants,labels =plant_labels,cex=0.7, col=colors)
par(mar=c(0,0,4,0),oma=c(0,0,0,0))
legend(1,1,cex=0.7,pt.cex=25, c("Rubiaceae","Aspleniaceae","Compositae","Euphorbiaceae","Piperaceae","Acanthaceae","Dryopteridaceae","Cucurbitaceae","Rosaceae","Rutaceae","Urticaceae","Apocynaceae","Cyperaceae","Gramineae","Labiatae","Leguminosae","Menispermaceae","Rest (50 families)"),fill=colors)

As you can see the legend is not displayed proberly.

1)How can I move the pie chart as well as the legend together to the left? I tried to work with "mar" and "omar", without any success.
2) How can I increase the legend font size without increasing the size of the "legend points"? I tried to do this with "cex" and "pt.cex2


Thank you very much
all the best
Michi

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shift pie chart

Adams, Jean
Michi,

The code that you shared was incomplete.  Two objects (plant_labels and
colors) were not defined.

The pie chart would be easier to interpret by direct labeling of slices,
rather than trying to decipher a color legend.  If you change the initial
angle of the first slice, you can rotate the pie in such a way that the
slices can be labelled with the full plant names with no overlap, even
without using a smaller font.

plants <- c(11, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 43)
plant.names <- c("Rubiaceae", "Aspleniaceae", "Compositae",
"Euphorbiaceae",
        "Piperaceae", "Acanthaceae", "Dryopteridaceae", "Cucurbitaceae",
"Rosaceae",
        "Rutaceae", "Urticaceae", "Apocynaceae", "Cyperaceae",
"Gramineae", "Labiatae",
        "Leguminosae", "Menispermaceae", "Rest (50 families)")
par(mar=c(2, 4, 2, 4))
pie(plants, labels=plant.names, init.angle=45)

Jean


Michael Eisenring <[hidden email]> wrote on 07/27/2012 05:15:17
AM:

>
> Dear R-help members,
> I did the following pie chart:
>
> R:Code=
>
> plants<-c(11,5,4,4,4,3,3,3,3,3,3,2,2,2,2,2,2,43)
> pie(plants,labels =plant_labels,cex=0.7, col=colors)
> par(mar=c(0,0,4,0),oma=c(0,0,0,0))
> legend(1,1,cex=0.7,pt.cex=25, c
>
("Rubiaceae","Aspleniaceae","Compositae","Euphorbiaceae","Piperaceae","Acanthaceae","Dryopteridaceae","Cucurbitaceae","Rosaceae","Rutaceae","Urticaceae","Apocynaceae","Cyperaceae","Gramineae","Labiatae","Leguminosae","Menispermaceae","Rest

> (50 families)"),fill=colors)
>
> As you can see the legend is not displayed proberly.
>
> 1)How can I move the pie chart as well as the legend together to the
> left? I tried to work with "mar" and "omar", without any success.
> 2) How can I increase the legend font size without increasing the
> size of the "legend points"? I tried to do this with "cex" and "pt.cex2
>
>
> Thank you very much
> all the best
> Michi

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.