geom_multi_raster {plothelper}R Documentation

Geom Layer for Drawing Multiple Rasters

Description

Unlike annotation_raster which draws only 1 raster, this layer draws one or more rasters at the same time. The data must be a tbl object created by package tibble and the reason is that, as we must give each rectangle a vector of colors, the column that contains these vectors of colors must be a list rather than a vector. A list can be a column for tbl object, not for a normal data frame. See examples. Accepted properties are:

Usage

geom_multi_raster(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  flip = FALSE,
  ...
)

Arguments

mapping

aes mapping.

data

data. It should be a tbl object.

stat

stat.

position

position.

na.rm

logical, whether to remove NA values.

show.legend

This will not be used because the layer does not create any legend.

inherit.aes

logical, whether to inherit aes from ggplot().

flip

see description.

...

additional parameters.

Examples

# Example 1: use vectors and a list. 
mycolor=list(
	c1=matrix(c("red", "blue", "green", "yellow"), nrow=2), 
	c2=matrix(c("green", "yellow")), 
	c3=matrix(c("purple", "red")))
xmin=1: 3
xmax=(1: 3)+0.8 
ymin=c(0, 1, 2)
ymax=c(1, 3, 5)
ggplot()+
	geom_multi_raster(aes(xmin=xmin, xmax=xmax, 
	ymin=ymin, ymax=ymax, raster=mycolor))
#
# Example 2: the same as example 1
# except flip=TRUE.
ggplot()+coord_flip()+
	geom_multi_raster(aes(xmin=xmin, xmax=xmax, 
	ymin=ymin, ymax=ymax, raster=mycolor), flip=TRUE)

[Package plothelper version 0.1.9 Index]