grid.curve.html
6.48 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Draw a Curve Between Locations</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for grid.curve {grid}"><tr><td>grid.curve {grid}</td><td align="right">R Documentation</td></tr></table>
<h2>Draw a Curve Between Locations</h2>
<h3>Description</h3>
<p>
These functions create and draw a curve from one location
to another.
</p>
<h3>Usage</h3>
<pre>
grid.curve(...)
curveGrob(x1, y1, x2, y2, default.units = "npc",
curvature = 1, angle = 90, ncp = 1, shape = 0.5,
square = TRUE, squareShape = 1,
inflect = FALSE, arrow = NULL, open = TRUE,
debug = FALSE,
name = NULL, gp = gpar(), vp = NULL)
arcCurvature(theta)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x1</code></td>
<td>
A numeric vector or unit object specifying the x-location of
the start point.</td></tr>
<tr valign="top"><td><code>y1</code></td>
<td>
A numeric vector or unit object specifying the y-location of
the start point.</td></tr>
<tr valign="top"><td><code>x2</code></td>
<td>
A numeric vector or unit object specifying the x-location of
the end point.</td></tr>
<tr valign="top"><td><code>y2</code></td>
<td>
A numeric vector or unit object specifying the y-location of
the end point.</td></tr>
<tr valign="top"><td><code>default.units</code></td>
<td>
A string indicating the default units to use
if <code>x1</code>, <code>y1</code>, <code>x2</code> or <code>y2</code>
are only given as numeric values.</td></tr>
<tr valign="top"><td><code>curvature</code></td>
<td>
A numeric value giving the amount of curvature.
Negative values produce left-hand curves, positive values
produce right-hand curves, and zero produces a straight line.</td></tr>
<tr valign="top"><td><code>angle</code></td>
<td>
A numeric value between 0 and 180,
giving an amount to skew the control
points of the curve. Values less than 90 skew the curve towards
the start point and values greater than 90 skew the curve
towards the end point.</td></tr>
<tr valign="top"><td><code>ncp</code></td>
<td>
The number of control points used to draw the curve.
More control points creates a smoother curve.</td></tr>
<tr valign="top"><td><code>shape</code></td>
<td>
A numeric vector of values between -1 and 1, which
control the shape of the curve relative to its control points.
See <code>grid.xspline</code> for more details.</td></tr>
<tr valign="top"><td><code>square</code></td>
<td>
A logical value that controls whether control
points for the curve are created city-block fashion or
obliquely. When <code>ncp</code> is 1 and <code>angle</code> is 90,
this is typically <code>TRUE</code>, otherwise this should probably
be set to <code>FALSE</code> (see Examples below).</td></tr>
<tr valign="top"><td><code>squareShape</code></td>
<td>
A <code>shape</code> value to control the behaviour
of the curve relative to any additional control point that
is inserted if <code>square</code> is <code>TRUE</code>.</td></tr>
<tr valign="top"><td><code>inflect</code></td>
<td>
A logical value specifying whether the curve
should be cut in half and inverted (see Examples below).</td></tr>
<tr valign="top"><td><code>arrow</code></td>
<td>
A list describing arrow heads to place at either end
of the curve, as produced by the <code>arrow</code> function.</td></tr>
<tr valign="top"><td><code>open</code></td>
<td>
A logical value indicating whether to close the curve
(connect the start and end points).</td></tr>
<tr valign="top"><td><code>debug</code></td>
<td>
A logical value indicating whether debugging
information should be drawn.</td></tr>
<tr valign="top"><td><code>name</code></td>
<td>
A character identifier. </td></tr>
<tr valign="top"><td><code>gp</code></td>
<td>
An object of class <code>gpar</code>, typically the output
from a call to the function <code>gpar</code>. This is basically
a list of graphical parameter settings.</td></tr>
<tr valign="top"><td><code>vp</code></td>
<td>
A Grid viewport object (or NULL).</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
Arguments to be passed to <code>curveGrob</code>.</td></tr>
<tr valign="top"><td><code>theta</code></td>
<td>
An angle (in degrees).</td></tr>
</table>
<h3>Details</h3>
<p>
Both functions create a curve grob (a graphical object describing an
curve), but only <code>grid.curve</code>
draws the curve.
</p>
<p>
The <code>arcCurvature</code> function can be used to calculate a
<code>curvature</code> such that control points are generated on
an arc corresponding to angle <code>theta</code>. This is typically
used in conjunction with a large <code>ncp</code> to produce a curve
corresponding to the desired arc.
</p>
<h3>Value</h3>
<p>
A grob object.</p>
<h3>See Also</h3>
<p>
<a href="Grid.html">Grid</a>,
<code><a href="viewport.html">viewport</a></code>,
<code><a href="grid.xspline.html">grid.xspline</a></code>,
<code><a href="arrow.html">arrow</a></code>
</p>
<h3>Examples</h3>
<pre>
curveTest <- function(i, j, ...) {
pushViewport(viewport(layout.pos.col=j, layout.pos.row=i))
do.call("grid.curve", c(list(x1=.25, y1=.25, x2=.75, y2=.75),
if (is.null(...)) NULL else list(...)))
grid.text(sub("list", "", deparse(substitute(list(...)))),
y=unit(1, "npc"))
popViewport()
}
# grid.newpage()
pushViewport(plotViewport(c(0, 0, 1, 0),
layout=grid.layout(2, 1, heights=c(2, 1))))
pushViewport(viewport(layout.pos.row=1,
layout=grid.layout(3, 3, respect=TRUE)))
curveTest(1, 1, NULL)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport()
pushViewport(viewport(layout.pos.row=2,
layout=grid.layout(3, 3)))
curveTest(1, 1, NULL)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport(2)
</pre>
<hr><div align="center">[Package <em>grid</em> version 2.5.1 <a href="00Index.html">Index]</a></div>
</body></html>