View source: R/VizCombinedMap.R
| VizCombinedMap | R Documentation |
Plot a number a two dimensional matrices with (longitude, latitude) dimensions on a single map with the cylindrical equidistant latitude and longitude projection.
VizCombinedMap(
maps,
lon,
lat,
map_select_fun,
display_range,
map_dim = "map",
brks = NULL,
cols = NULL,
bar_limits = NULL,
triangle_ends = c(FALSE, FALSE),
col_inf = NULL,
col_sup = NULL,
col_unknown_map = "white",
mask = NULL,
mask_color = "grey",
col_mask = NULL,
dots = NULL,
bar_titles = NULL,
bar_label_scale = 1,
legend_scale = NULL,
cex_bar_titles = 1.5,
margin_scale = NULL,
plot_margin = NULL,
bar_extra_margin = c(2, 0, 2, 0),
fileout = NULL,
width = 8,
height = 5,
size_units = "in",
res = 100,
drawleg = TRUE,
return_leg = FALSE,
...
)
maps |
List of matrices to plot, each with (longitude, latitude) dimensions, or 3-dimensional array with the dimensions (longitude, latitude, map). Dimension names are required. |
lon |
Vector of longitudes. Must match the length of the corresponding dimension in 'maps'. |
lat |
Vector of latitudes. Must match the length of the corresponding dimension in 'maps'. |
map_select_fun |
Function that selects, for each grid point, which value
to take among all the provided maps. This function receives as input a
vector of values for a same grid point for all the provided maps, and must
return a single selected value (not its index!) or NA. For example, the
|
display_range |
Range of values to be displayed for all the maps. This must be a numeric vector c(range min, range max). The values in the parameter 'maps' can go beyond the limits specified in this range. If the selected value for a given grid point (according to 'map_select_fun') falls outside the range, it will be coloured with 'col_unknown_map'. |
map_dim |
Optional name for the dimension of 'maps' along which the multiple maps are arranged. Only applies when 'maps' is provided as a 3-dimensional array. Takes the value 'map' by default. |
brks |
Colour levels to be sent to VizEquiMap. This parameter is optional and adjusted automatically by the function. |
cols |
List of vectors of colours to be sent to VizEquiMap for the colour bar of each map. This parameter is optional and adjusted automatically by the function (up to 5 maps). The colours provided for each colour bar will be automatically interpolated to match the number of breaks. Each item in this list can be named, and the name will be used as title for the corresponding colour bar (equivalent to the parameter 'bar_titles'). |
bar_limits |
A numeric vector of 2 indicating the range of color bar. The default is NULL, and the function will decide the range automatically. |
triangle_ends |
A logical vector of two indicating if the lower and upper triangles of the color bar should be plotted. The default is c(FALSE, FALSE). |
col_inf |
A character string of recognized color name or code indicating the color of the lower triangle of the color bar. The default is NULL. |
col_sup |
A character string of recognized color name or code indicating the color of the upper triangle of the color bar. The default is NULL. |
col_unknown_map |
Colour to use to paint the grid cells for which a map is not possible to be chosen according to 'map_select_fun' or for those values that go beyond 'display_range'. Takes the value 'white' by default. |
mask |
Optional numeric array with dimensions (latitude, longitude), with values in the range [0, 1], indicating the opacity of the mask over each grid point. Cells with a 0 will result in a totally opaque superimposed pixel coloured in 'mask_color', whereas cells with a 1 will have no mask and remain totally visible. |
mask_color |
Colour to be used for the superimposed mask (if specified in 'mask'). Takes the value 'grey' by default. |
col_mask |
Deprecated. Use 'mask_color' instead. |
dots |
Array of same dimensions as 'var' or with dimensions c(n, dim(var)), where n is the number of dot/symbol layers to add to the plot. A value of TRUE at a grid cell will draw a dot/symbol on the corresponding square of the plot. By default all layers provided in 'dots' are plotted with dots, but a symbol can be specified for each of the layers via the parameter 'dot_symbol'. |
bar_titles |
Optional vector of character strings providing the titles to be shown on top of each of the colour bars. |
bar_label_scale |
Scale factor for the size of the colour bar labels. Takes 1 by default. |
legend_scale |
Deprecated. Use 'bar_label_scale' instead. |
cex_bar_titles |
Scale factor for the sizes of the bar titles. Takes 1.5 by default. |
margin_scale |
Numeric vector of length 4 for the margin sizes in the following order: bottom, left, top, and right. If not specified (NULL), the default of par("mar"), c(5.1, 4.1, 4.1, 2.1), is used. Default is NULL. |
plot_margin |
Deprecated. Use 'margin_scale' instead. |
bar_extra_margin |
A numeric vector of 4 indicating the extra margins to be added around the color bar, in the format c(y1, x1, y2, x2). The units are margin lines. The default values are c(2, 0, 2, 0). |
fileout |
File where to save the plot. If not specified (default) a graphics device will pop up. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff |
width |
File width, in the units specified in the parameter 'size_units' (inches by default). Takes 8 by default. |
height |
File height, in the units specified in the parameter 'size_units' (inches by default). Takes 5 by default. |
size_units |
Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. |
res |
Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. |
drawleg |
Where to draw the common colour bar. Can take values TRUE,
FALSE or: |
return_leg |
A logical value indicating if the color bars information should be returned by the function. If TRUE, the function doesn't plot the color bars but still creates the layout with color bar areas, and the arguments for GradientCatsColorBar() or ColorBarContinuous() will be returned. It is convenient for users to adjust the color bars manually. The default is FALSE, the color bars will be plotted directly. |
... |
Additional parameters to be passed on to |
Invisibly returns NULL when return_leg = FALSE
(default). When return_leg = TRUE, returns a list with color bar
configuration information.
Nicolau Manubens, nicolau.manubens@bsc.es
Veronica Torralba, veronica.torralba@bsc.es
VizCombinedMap and VizEquiMap
# Simple example
x <- array(1:(20 * 10), dim = c(lat = 10, lon = 20)) / 200
a <- x * 0.6
b <- (1 - x) * 0.6
c <- 1 - (a + b)
lons <- seq(0, 359.5, length = 20)
lats <- seq(-89.5, 89.5, length = 10)
VizCombinedMap(list(a, b, c), lons, lats,
toptitle = 'Maximum map',
map_select_fun = max,
display_range = c(0, 1),
bar_titles = paste('% of belonging to', c('a', 'b', 'c')),
drawleg = FALSE, brks = 20, width = 8, height = 5)
# Mask example
lons2 <- c(0:40)
lats2 <- 51:26
data <- rnorm(41 * 26 * 3)
dim(data) <- c(map = 3, lon = 41, lat = 26)
mask <- sample(c(0,1), replace = TRUE, size = 41 * 26)
dim(mask) <- c(lat = 26, lon = 41)
VizCombinedMap(data, lon = lons2, lat = lats2, map_select_fun = max,
display_range = range(data), mask = mask,
drawleg = FALSE, width = 14, height = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.