| pielegend-methods | R Documentation |
This function can be used to add legends to pie charts produced using pieplot.
## S4 method for signature 'Parsimnet,Haplotype'
pielegend(p,h,net=1,factors,...)
p |
a |
h |
a |
net |
a numeric vector of length one indicating which network to plot. |
factors |
a vector or factor giving the grouping variable (populations, species, etc.), with one element per individual. |
... |
arguments to be passed to |
This method calls legend {graphics}, some default parameters changed:
an integer or character vector for the edge colors. By default, it is rainbow.
an integer or character vector for the filling colors. By default, it is rainbow
a numeric or character vector to appear in the legend. By default, it is the levels of the grouping factor for haplotypes.
position of the legend. Default is set to "topright".
See ‘ legend {graphics}’
signature(p = "Parsimnet", h = "Haplotype")Caner Aktas, caktas.aca@gmail.com.
plot,Parsimnet-method,floating.pie, plot.default, plot.network.default and legend.
data("dna.obj")
x<-dna.obj
h<-haplotypes::haplotype(x)
### Statistical parsimony with 95% connection limit
p<-parsimnet(x)
#randomly generated populations
pop<-c("pop1","pop2","pop3","pop4","pop5","pop6","pop7","pop8")
set.seed(5)
pops<-sample(pop,nrow(x),replace=TRUE)
## Plotting with default parameters.
pieplot(p,h,1, pops)
## Add legend with default parameters.
pielegend(p,h,1,pops)
## Change colors for the populations.
#8 colors for 8 populations
cols<-colors()[c(30,369,552,558,538,642,142,91)]
pieplot(p,h,1, pops,col=cols)
pielegend(p,h,1,pops,col= cols)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.