Repository navigation
Expand file tree
/
Copy pathquilt.plot.html
More file actions
174 lines (144 loc) · 5.27 KB
/
Copy pathquilt.plot.html
File metadata and controls
174 lines (144 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Image plot for irregular spatial data.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>
<table width="100%" summary="page for quilt.plot {fields}"><tr><td>quilt.plot {fields}</td><td style="text-align: right;">R Documentation</td></tr></table>
<h2>Image plot for irregular spatial data. </h2>
<h3>Description</h3>
<p>Given a vector of z values associated with 2-d locations this
function produces an
image-like plot where the locations are discretized to a grid and the z
values are coded as a color level from a color scale. </p>
<h3>Usage</h3>
<pre>
quilt.plot(x, y, z, nx = 64, ny = 64, grid = NULL,
add.legend=TRUE,add=FALSE, nlevel=64,
col = tim.colors(nlevel),
nrow=NULL, ncol=NULL,FUN =
NULL, plot=TRUE, na.rm=FALSE, ...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>A vector of the x coordinates of the locations -or- a
a 2 column matrix of the x-y coordinates. </p>
</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
<p>A vector of the y coordinates -or- if the locations are passed
in x the z vector </p>
</td></tr>
<tr valign="top"><td><code>z</code></td>
<td>
<p>Values of the variable to be plotted.</p>
</td></tr>
<tr valign="top"><td><code>nlevel</code></td>
<td>
<p>Number of color levels.</p>
</td></tr>
<tr valign="top"><td><code>nx</code></td>
<td>
<p>Number of grid boxes in x if a grid is not specified.</p>
</td></tr>
<tr valign="top"><td><code>ny</code></td>
<td>
<p>Number of grid boxes in y. </p>
</td></tr>
<tr valign="top"><td><code>nrow</code></td>
<td>
<p>Depreciated, same as nx.</p>
</td></tr>
<tr valign="top"><td><code>ncol</code></td>
<td>
<p>Depreciated same as ny. </p>
</td></tr>
<tr valign="top"><td><code>grid</code></td>
<td>
<p>A grid in the form of a <code>grid list</code>. </p>
</td></tr>
<tr valign="top"><td><code>add.legend</code></td>
<td>
<p>If TRUE a legend color strip is added</p>
</td></tr>
<tr valign="top"><td><code>add</code></td>
<td>
<p>If FALSE add to existing plot.</p>
</td></tr>
<tr valign="top"><td><code>col</code></td>
<td>
<p>Color scale for the image, the default is tim.colors –
a pleasing spectrum.</p>
</td></tr>
<tr valign="top"><td><code>plot</code></td>
<td>
<p>If FALSE just returns the image object instead of plotting it.</p>
</td></tr>
<tr valign="top"><td><code>FUN</code></td>
<td>
<p>The function to apply to values that are common to a grid box. The default is to find the mean. (see <code>as.image</code>).</p>
</td></tr>
<tr valign="top"><td><code>na.rm</code></td>
<td>
<p>If FALSE NAs are not removed from zand so a grid box
even one of these values may be an NA. (See details below.)</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p> arguments to be passed to the image.plot function </p>
</td></tr>
</table>
<h3>Details</h3>
<p>This function combines the discretization to an image by the function
<code>as.image</code> and is then graphed by <code>image.plot</code>.
By default, locations that fall into the same grid box will have their
z values averaged. This also means that observations that are NA will
result in the grid box average also being NA and can produce unexpected
results because the NA patterns can dominate the figure. If you are
unsure of the effect try <code>na.rm = TRUE</code> for a comparison.
</p>
<p>A similar function exists in the lattice package and produces good
looking plots. The advantage of this fields version is that it uses the
standard R graphics functions and is written in R code. Also, the
aggregation to average values for z values in the same grid box allows
for different choices of grids. If two locations are very close,
separating them could result in very small boxes.
</p>
<p>As always, legend placement is never completely automatic. Place the
legend independently for more control, perhaps using <code>image.plot</code>
in tandem with <code>split.screen</code> or enlarging the plot margin
See <code>help(image.plot)</code> for examples of this function and these
strategies. </p>
<h3>Author(s)</h3>
<p>D.Nychka</p>
<h3>See Also</h3>
<p> as.image, image.plot, lattice, persp, drape.plot </p>
<h3>Examples</h3>
<pre>
data( ozone2)
# plot 16 day of ozone data set
quilt.plot( ozone2$lon.lat, ozone2$y[16,])
US( add=TRUE, col="grey", lwd=2)
#
# and ... if you are fussy
# do it again
# quilt.plot( ozone2$lon.lat, ozone2$y[16,],add=TRUE)
# to draw over the state boundaries.
#
### adding a common legend strip "by hand"
## and a custom color table
coltab<- two.colors( 256, middle="grey50" )
par( oma=c( 0,0,0,5)) # save some room for the legend
set.panel(2,2)
zr<- range( ozone2$y, na.rm=TRUE)
for( k in 1:4){
quilt.plot( ozone2$lon.lat, ozone2$y[15+k,], add.legend=FALSE,
zlim=zr, col=coltab, nx=40, ny=40)
US( add=TRUE)
}
par( oma=c(0,0,0,1))
image.plot(zlim=zr,legend.only=TRUE, col=coltab)
# may have to adjust number of spaces in oma to make this work.
</pre>
<hr /><div style="text-align: center;">[Package <em>fields</em> version 9.9 <a href="00Index.html">Index</a>]</div>
</body></html>