-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patharrow.plot.html
146 lines (114 loc) · 4.14 KB
/
arrow.plot.html
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
<!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: Adds arrows to a plot</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 arrow.plot {fields}"><tr><td>arrow.plot {fields}</td><td style="text-align: right;">R Documentation</td></tr></table>
<h2>
Adds arrows to a plot
</h2>
<h3>Description</h3>
<p>Adds arrows at specified points where the arrow lengths are scaled to
fit on
the plot in a reasonable manner. A classic use of this function is to
depict a vector field. At each point (x,y) we have a vector with
components (u,v). Like the arrows function this adds arrows to an
existing plot.
</p>
<h3>Usage</h3>
<pre>
arrow.plot(a1, a2, u = NA, v = NA, arrow.ex = 0.05,
xpd = TRUE, true.angle = FALSE, arrowfun=arrows,...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>a1</code></td>
<td>
<p>The x locations of the tails of the arrows or a 2 column matrix giving
the x and y coordinates of the arrow tails.
</p>
</td></tr>
<tr valign="top"><td><code>a2</code></td>
<td>
<p>The y locations of the tails of the arrows or a 2 column matrix giving
the u and v coordinates of the arrows.
</p>
</td></tr>
<tr valign="top"><td><code>u</code></td>
<td>
<p>The u components of the direction vectors if they are not specified in
the a1 argument
</p>
</td></tr>
<tr valign="top"><td><code>v</code></td>
<td>
<p>The v components of the direction vectors if they are not specified in
the a2 argument
</p>
</td></tr>
<tr valign="top"><td><code>arrow.ex</code></td>
<td>
<p>Controls the length of the arrows. The length is in terms of the fraction
of the shorter axis in the plot. So with a default of .05 20 arrows
of maximum length can line up end to end along the shorter axis.
</p>
</td></tr>
<tr valign="top"><td><code>xpd</code></td>
<td>
<p>If true does not clip arrows to fit inside the plot region, default is
not to clip.
</p>
</td></tr>
<tr valign="top"><td><code>true.angle</code></td>
<td>
<p>If true preserves the true angle of the (u,v) pair on the plot. E.g. if
(u,v)=(1,1) then the arrow will be drawn at 45 degrees.
</p>
</td></tr>
<tr valign="top"><td><code>arrowfun</code></td>
<td>
<p>The actual arrow function to use. The default is standard R <code>arrows</code>.
However, Tamas K Papp suggests <code>p.arrows</code> from sfsmisc which makes prettier
arrows.
</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>Graphics arguments passed to the arrows function that can can change the
color or arrow sizes. See help on this for
details.
</p>
</td></tr>
</table>
<h3>Details</h3>
<p>This function is useful because (u,v) may be in very different scales
from the locations (x,y). So some careful scaling is needed to plot the
arrows.
The only tricky thing about this function is whether you want the true
angles on the plot. For overlaying a vector field on top of contours
that are the streamlines true.angle should be false. In this case you
want u and v to be scaled in the same way as the x and y variables.
If the scaling is not the same then the arrows will not look like tangent
vectors to the streamlines.
An application where the absolute angles are meaningful might be the hands of a
clock showing different times zones on a world map. Here true.angle=T is
appropriate, the clock hands should preserve the right angles.
</p>
<h3>See Also</h3>
<p>arrows</p>
<h3>Examples</h3>
<pre>
#
# 20 random directions at 20 random points
x<- runif( 20)
y<- runif( 20)
u<- rnorm( 20)
v<- rnorm( 20)
plot( x,y)
arrow.plot( x,y,u,v) # a default that is unattractive
plot( x,y, type="n")
arrow.plot( x,y,u,v, arrow.ex=.2, length=.1, col='green', lwd=2)
# thicker lines in green, smaller heads and longer tails. Note length, col and lwd are
# options that the arrows function itself knows about.
</pre>
<hr /><div style="text-align: center;">[Package <em>fields</em> version 9.9 <a href="00Index.html">Index</a>]</div>
</body></html>