pielegend-methods: Add Legends to Plots

pielegend-methodsR Documentation

Add Legends to Plots

Description

This function can be used to add legends to pie charts produced using pieplot.

Usage

## S4 method for signature 'Parsimnet,Haplotype'
pielegend(p,h,net=1,factors,...)

Arguments

p

a Parsimnet object.

h

a Haplotype object.

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 legend and others. See ‘Details’

Details

This method calls legend {graphics}, some default parameters changed:

col

an integer or character vector for the edge colors. By default, it is rainbow.

fill

an integer or character vector for the filling colors. By default, it is rainbow

legend

a numeric or character vector to appear in the legend. By default, it is the levels of the grouping factor for haplotypes.

x

position of the legend. Default is set to "topright".

Value

See ‘ legend {graphics}

Methods

signature(p = "Parsimnet", h = "Haplotype")

Author(s)

Caner Aktas, caktas.aca@gmail.com.

See Also

plot,Parsimnet-method,floating.pie, plot.default, plot.network.default and legend.

Examples

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)


haplotypes documentation built on July 26, 2023, 5:22 p.m.