| Line 1... |
Line 1... |
| 1 |
% File src/library/graphics/man/image.Rd
|
1 |
% File src/library/graphics/man/image.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2017 R Core Team
|
3 |
% Copyright 1995-2019 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{image}
|
6 |
\name{image}
|
| 7 |
\alias{image}
|
7 |
\alias{image}
|
| 8 |
\alias{image.default}
|
8 |
\alias{image.default}
|
| 9 |
\title{Display a Color Image}
|
9 |
\title{Display a Color Image}
|
| 10 |
\usage{
|
10 |
\usage{
|
| 11 |
image(x, \dots)
|
11 |
image(x, \dots)
|
| 12 |
|
12 |
|
| 13 |
\method{image}{default}(x, y, z, zlim, xlim, ylim,
|
13 |
\method{image}{default}(x, y, z, zlim, xlim, ylim,
|
| 14 |
col = hcl.colors(12, "YlOrRd"),
|
14 |
col = hcl.colors(12, "YlOrRd", rev = TRUE),
|
| 15 |
add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
|
15 |
add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
|
| 16 |
breaks, oldstyle = FALSE, useRaster, \dots)
|
16 |
breaks, oldstyle = FALSE, useRaster, \dots)
|
| 17 |
}
|
17 |
}
|
| 18 |
\arguments{
|
18 |
\arguments{
|
| 19 |
\item{x, y}{locations of grid lines at which the values in \code{z} are
|
19 |
\item{x, y}{locations of grid lines at which the values in \code{z} are
|
| Line 33... |
Line 33... |
| 33 |
intervals cover the range, so that values just outside the range
|
33 |
intervals cover the range, so that values just outside the range
|
| 34 |
will be plotted.}
|
34 |
will be plotted.}
|
| 35 |
\item{xlim, ylim}{ranges for the plotted \code{x} and \code{y} values,
|
35 |
\item{xlim, ylim}{ranges for the plotted \code{x} and \code{y} values,
|
| 36 |
defaulting to the ranges of \code{x} and \code{y}.}
|
36 |
defaulting to the ranges of \code{x} and \code{y}.}
|
| 37 |
\item{col}{a list of colors such as that generated by
|
37 |
\item{col}{a list of colors such as that generated by
|
| 38 |
\code{\link{rainbow}}, \code{\link{heat.colors}},
|
- |
|
| 39 |
\code{\link{topo.colors}}, \code{\link{terrain.colors}} or similar
|
38 |
\code{\link{hcl.colors}}, \code{\link{gray.colors}} or similar
|
| 40 |
functions.}
|
39 |
functions.}
|
| 41 |
\item{add}{logical; if \code{TRUE}, add to current plot (and disregard
|
40 |
\item{add}{logical; if \code{TRUE}, add to current plot (and disregard
|
| 42 |
the following four arguments). This is rarely useful because
|
41 |
the following four arguments). This is rarely useful because
|
| 43 |
\code{image} \sQuote{paints} over existing graphics.}
|
42 |
\code{image} \sQuote{paints} over existing graphics.}
|
| 44 |
\item{xaxs, yaxs}{style of x and y axis. The default \code{"i"} is
|
43 |
\item{xaxs, yaxs}{style of x and y axis. The default \code{"i"} is
|
| Line 65... |
Line 64... |
| 65 |
Creates a grid of colored or gray-scale rectangles with colors
|
64 |
Creates a grid of colored or gray-scale rectangles with colors
|
| 66 |
corresponding to the values in \code{z}. This can be used to display
|
65 |
corresponding to the values in \code{z}. This can be used to display
|
| 67 |
three-dimensional or spatial data aka \emph{images}.
|
66 |
three-dimensional or spatial data aka \emph{images}.
|
| 68 |
This is a generic function.
|
67 |
This is a generic function.
|
| 69 |
|
68 |
|
| 70 |
The functions \code{\link{hcl.colors}}, \code{\link{terrain.colors}}
|
69 |
The function \code{\link{hcl.colors}} provides a broad range of sequential
|
| 71 |
and \code{\link{topo.colors}} create heat-spectrum (red to white) and
|
- |
|
| 72 |
topographical color schemes suitable for displaying ordered data, with
|
70 |
color palettes that are suitable for displaying ordered data, with
|
| 73 |
\code{n} giving the number of colors desired.
|
71 |
\code{n} giving the number of colors desired.
|
| 74 |
}
|
72 |
}
|
| 75 |
\details{
|
73 |
\details{
|
| 76 |
The length of \code{x} should be equal to the \code{nrow(z)+1} or
|
74 |
The length of \code{x} should be equal to the \code{nrow(z)+1} or
|
| 77 |
\code{nrow(z)}. In the first case \code{x} specifies the boundaries
|
75 |
\code{nrow(z)}. In the first case \code{x} specifies the boundaries
|
| Line 134... |
Line 132... |
| 134 |
look nicer (but are less modular),
|
132 |
look nicer (but are less modular),
|
| 135 |
\code{\link{contour}};
|
133 |
\code{\link{contour}};
|
| 136 |
The \CRANpkg{lattice} equivalent of \code{image} is
|
134 |
The \CRANpkg{lattice} equivalent of \code{image} is
|
| 137 |
\code{\link[lattice]{levelplot}}.
|
135 |
\code{\link[lattice]{levelplot}}.
|
| 138 |
|
136 |
|
| 139 |
\code{\link{heat.colors}}, \code{\link{topo.colors}},
|
137 |
\code{\link{hcl.colors}}, \code{\link{gray.colors}},
|
| 140 |
\code{\link{terrain.colors}}, \code{\link{rainbow}},
|
- |
|
| 141 |
\code{\link{hsv}}, \code{\link{par}}.
|
138 |
\code{\link{hcl}}, \code{\link{hsv}}, \code{\link{par}}.
|
| 142 |
|
139 |
|
| 143 |
\code{\link{dev.capabilities}} to see if \code{useRaster = TRUE} is
|
140 |
\code{\link{dev.capabilities}} to see if \code{useRaster = TRUE} is
|
| 144 |
supported on the current device.
|
141 |
supported on the current device.
|
| 145 |
}
|
142 |
}
|
| 146 |
|
143 |
|
| 147 |
\examples{
|
144 |
\examples{
|
| 148 |
require(grDevices) # for colours
|
145 |
require("grDevices") # for colours
|
| 149 |
x <- y <- seq(-4*pi, 4*pi, len = 27)
|
146 |
x <- y <- seq(-4*pi, 4*pi, length.out = 27)
|
| 150 |
r <- sqrt(outer(x^2, y^2, "+"))
|
147 |
r <- sqrt(outer(x^2, y^2, "+"))
|
| 151 |
image(z = z <- cos(r^2)*exp(-r/6), col = gray((0:32)/32))
|
148 |
image(z = z <- cos(r^2)*exp(-r/6), col = gray.colors(33))
|
| 152 |
image(z, axes = FALSE, main = "Math can be beautiful ...",
|
149 |
image(z, axes = FALSE, main = "Math can be beautiful ...",
|
| 153 |
xlab = expression(cos(r^2) * e^{-r/6}))
|
150 |
xlab = expression(cos(r^2) * e^{-r/6}))
|
| 154 |
contour(z, add = TRUE, drawlabels = FALSE)
|
151 |
contour(z, add = TRUE, drawlabels = FALSE)
|
| 155 |
|
152 |
|
| 156 |
# Volcano data visualized as matrix. Need to transpose and flip
|
153 |
# Volcano data visualized as matrix. Need to transpose and flip
|
| Line 158... |
Line 155... |
| 158 |
image(t(volcano)[ncol(volcano):1,])
|
155 |
image(t(volcano)[ncol(volcano):1,])
|
| 159 |
|
156 |
|
| 160 |
# A prettier display of the volcano
|
157 |
# A prettier display of the volcano
|
| 161 |
x <- 10*(1:nrow(volcano))
|
158 |
x <- 10*(1:nrow(volcano))
|
| 162 |
y <- 10*(1:ncol(volcano))
|
159 |
y <- 10*(1:ncol(volcano))
|
| 163 |
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
|
160 |
image(x, y, volcano, col = hcl.colors(100, "terrain"), axes = FALSE)
|
| 164 |
contour(x, y, volcano, levels = seq(90, 200, by = 5),
|
161 |
contour(x, y, volcano, levels = seq(90, 200, by = 5),
|
| 165 |
add = TRUE, col = "peru")
|
162 |
add = TRUE, col = "brown")
|
| 166 |
axis(1, at = seq(100, 800, by = 100))
|
163 |
axis(1, at = seq(100, 800, by = 100))
|
| 167 |
axis(2, at = seq(100, 600, by = 100))
|
164 |
axis(2, at = seq(100, 600, by = 100))
|
| 168 |
box()
|
165 |
box()
|
| 169 |
title(main = "Maunga Whau Volcano", font.main = 4)
|
166 |
title(main = "Maunga Whau Volcano", font.main = 4)
|
| 170 |
}
|
167 |
}
|