Description Usage Arguments Details Author(s) References Examples

View source: R/draw.barplot2D.R

2-Dimensional barplots are essentially rectangular pieplots. These plots can be used to display proportional data in certain locations on a map.

1 2 |

`x, y` |
vector with x and y-locations of the centre of the 2D barplots |

`z` |
array where the rows correspond to |

`width` |
the width of the (largest) 2D barplot (user coordinate units). This can be a single value or a vector with the same length as |

`height` |
the width of the (largest) 2D barplot see |

`scale` |
logical, should the surface area of each 2d-barplot automatically be scaled to the sum of its z-values? Only works if |

`col` |
a vector (same length as the number of columns in |

`col.frame` |
the colour of the frame of the 2D barplot |

`lwd.frame` |
the line width of the frame of the 2D barplot |

`silent` |
logical, should a progress message be displayed in the console? Defaults to |

`...` |
arguments to be passed to |

The algorithm that determines the location of each rectangle within the 2D-barplot is as follows: 1) Start with a rectangle representing the highest value of `z`

. 2) Try to put the first rectangle on the left. 3) If it too elongated, try to put two rectangles, on top of each other, on the left. 4) When you have placed those rectangles, proceed with the remaining rectangles.

More precisely, we choose the number of rectables to stack so as to minimize the following penalty: penalty for the first rectangle in the stack + penalty for the last where the penalty of a rectangle is: `ratio - 1.1`

. where `ratio`

is the ratio of the longer side by the smaller.

Adapted by Hans Gerritsen

This function was adapted from http://zoonek2.free.fr/UNIX/48_R/03.html

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
data(landings)
data(coast)
xlim <- c(-15,0)
ylim <- c(50,56)
xyz <- make.xyz(landings$Lon,landings$Lat,landings$LiveWeight,landings$Species)
col <- rainbow(5)
basemap(xlim, ylim, main = "Species composition of gadoid landings")
draw.shape(coast, col="cornsilk")
draw.barplot2D(xyz$x, xyz$y, xyz$z, width = 0.8, height = 0.4, col=col)
legend("topright", legend=colnames(xyz$z), fill=col, bg="lightblue", inset=0.02)
basemap(xlim, ylim, main = "Species composition of gadoid landings")
draw.shape(coast, col="cornsilk")
draw.barplot2D(xyz$x, xyz$y, xyz$z, width = 1, height = 0.5, scale=TRUE, col=col)
legend("topright", legend=colnames(xyz$z), fill=col, bg="lightblue", inset=0.02)
``` |

mapplots documentation built on May 22, 2018, 5:08 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.