SpatEntropy (version 0.1.0)

plot_lattice: Plot lattice data.

Description

plot_lattice produces a gray scale plot of a matrix of categorical data.

Usage

plot_lattice(data, win = spatstat::owin(xrange = c(1, ncol(data)), yrange =
  c(1, nrow(data))), gray.ext = c(1, 0), main = "", ribbon = TRUE)

Arguments

data

A matrix, can be numeric, factor, character.

win

An owin object, the observation area (see package spatstat). Automatically created, if not provided, by setting the pixel size as 1.

gray.ext

A vector of length two with the two extremes of the gray scale (between 0 and 1).

main

Optional, a character string with the plot main title.

ribbon

Logical, whether to display a ribbon showing the colour map.

Value

A gray scale plot of the categorical lattice dataset.

Details

This function allows to easily produce a gray scale map given a matrix of categorical data and, optionally, the observation area. It ensures that data is displayed following the matrix order (where position (1,1) corresponds to the top-left corner of plot), avoiding risks of row inversion or transposition. A few #'options may be tuned: the extent of the gray scale, the title and the legend.

Examples

Run this code
# NOT RUN {
data.lat=matrix(sample(c("a","b","c"), 100, replace=TRUE), nrow=10)
plot_lattice(data.lat)

plot_lattice(data.lat, win=square(100))

plot_lattice(data.lat, win=square(10), gray.ext=c(1,.4), ribbon=FALSE)

# }

Run the code above in your browser using DataLab