recluster.plot.pie: Plotting pies with RGB colours on a custom coordinate space

Description Usage Arguments Value Author(s) References Examples

View source: R/recluster.plot.pie.R

Description

This function groups cases based on a space grid in a user defined set of coordinates (usually longitude and latitude) and plot them in pies using RGB colours. The function can either use an output from recluster.col function or compute colours based on any distance matrix where the cases are in the same order as in the latitude and longitude data.

Usage

1
2
3
recluster.plot.pie(long, lat, mat=NULL, distance=NULL, loc=NULL, areas=NULL, square=2,
                   map=NULL,add=FALSE,minsize=NULL,proportional=T,xlim=NULL,ylim=NULL,
                   main=NULL,xlab=NULL,ylab=NULL,...)

Arguments

long

A vector indicating longitude for cases.

lat

A vector indicating latitude for cases.

mat

A matrix inherited by recluster.col.

distance

A dissimilarity matrix for cases.

loc

A list of localities to group cases, if available.

square

The grid to be used to divide cases into groups (2 degrees latitude and longitude by default).

areas

An additional vector to divide groups (e.g. islands versus continents).

map

A map to be plotted.

add

A logical. If TRUE then the points are added to an existing graph.

minsize

Dimension for the dimension of a single-case pie.

proportional

A logical. If TRUE then the point area is proportional to the number of cases.

xlim

Limits of the plot in the x-axis.

ylim

Limits of the plot in the y-axis.

main

The title of the graph.

xlab

The label of x-axis

ylab

The label of y-axis

...

See par() for other graphical parameters

Value

A colour plot.

Author(s)

Leonardo Dapporto

References

Hernandez Roldan J.L., Dapporto L., Dinca V, Vicente J.C., Hornett E.A., Sichova J., Lukhtanov V.L., Talavera G. & Vila, R. Integrative analyses unveil speciation linked to host plant shift in Spialia butterflies. Molecular Ecology (2016) 25: 4267-4284.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# create a virtual dataset and a corresponding distance matrix
lat<-runif(50,min=20,max=40)
long<-runif(50,min=20,max=40)
datavirtual<-data.frame(replicate(20,sample(0:1,50,rep=TRUE)))
dist<-recluster.dist(datavirtual)

# Make a plot using a custom distance
recluster.plot.pie(long,lat,distance=dist,xlab="Longitude",ylab="Latitude")

# Make a plot using a recluster.col matrix
colours<-recluster.col(cmdscale(dist))
recluster.plot.pie(long,lat,mat=colours,xlab="Longitude",ylab="Latitude")

# Make points of equal size
recluster.plot.pie(long,lat,mat=colours,xlab="Longitude", proportional=FALSE,
ylab="Latitude")

# Reduce the grid
recluster.plot.pie(long,lat,distance=dist,square=1, xlab="Longitude",ylab="Latitude")

# Reduce the size of the plots
recluster.plot.pie(long,lat,distance=dist,xlab="Longitude",ylab="Latitude", minsize=0.5)
# Use a custom colour matrix
pcoa<-cmdscale(dist)
colour<-recluster.col(pcoa)
recluster.plot.col(colour)
recluster.plot.pie(long,lat,mat=colour,xlab="Longitude",ylab="Latitude")

# Include an additional factor for separating dots in groups(e.g. two continents)
continent<-rep(1,50)
continent[which(long>25)]<-2
recluster.plot.pie(long,lat,distance=dist,xlab="Longitude",ylab="Latitude", 
areas=continent)

recluster documentation built on July 27, 2020, 1:15 a.m.