Skip to contents

Plots a color matrix, representing the values stored in x.
Originally, it was thought to represent the amount of days with information per year in a set of gauging stations, but it can be used for plotting the information stored in any two dimensional matrix.

Usage

matrixplot(x, ColorRamp="Days", ncolors = 70, main = "", ...)

Arguments

x

matrix to be plotted. Originally:
-) Each column of x represent a different gauging station, and it stores the values measured on it
-) Each row of x represent the years, and they stores the amount of days with information in each station

ColorRamp

Character or function defining a personalized color ramp for plotting the maps.
Valid character values are in c("Days", "Precipitation", "Temperature", "PCPAnomaly", "PCPAnomaly2" "TEMPAnomaly", "TEMPAnomaly2", "TEMPAnomaly3").

ncolors

numeric, indicating the number of color intervals that will be used for representing the information content of x.

main

Main title for the plot

...

further arguments passed to levelplot function (lattice package) or from other methods

Author

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

Note

Adapted from a not available web page (http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/r/matrix_contour/)

See also

Examples

## Loading the SanMartino precipitation data
data(SanMartinoPPts)

# Selecting only the values up to Dec/1960
x <- window(SanMartinoPPts, end=as.Date("1960-12-31"))

## Daily zoo to monthly zoo
m <- daily2monthly(x, FUN=sum, na.rm=TRUE)

# Creating a data.frame with monthly values per year in each column
M <- matrix(m, ncol=12, byrow=TRUE)
colnames(M) <- month.abb
rownames(M) <- unique(format(time(m), "%Y"))

# Plotting the monthly precipitation values from 1921 to 1960.
# Useful for identifying dry/wet months
matrixplot(M, ColorRamp="Precipitation", 
           main="Monthly precipitation at San Martino st., [mm/month]")