space.html
3.62 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>R: Space points in an x-y plot so they don't overlap.</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 space {gplots}"><tr><td>space {gplots}</td><td align="right">R Documentation</td></tr></table>
<h2>Space points in an x-y plot so they don't overlap.</h2>
<h3>Description</h3>
<p>
Space points in an x-y plot so they don't overlap.
</p>
<h3>Usage</h3>
<pre>
space(x, y, s=1/50, na.rm=TRUE, direction="x")
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
numeric vector of x coordonates.</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
numeric vector of x coordonates.</td></tr>
<tr valign="top"><td><code>s</code></td>
<td>
either a single numeric value or 2 element vector specifying
the minimum distance between points in the x and y dimensions as a
fraction of the x and y range. Defaults to 1/50.</td></tr>
<tr valign="top"><td><code>na.rm</code></td>
<td>
logical indicating whether pairs where one or both
elements are missing should be removed. Defaults to TRUE.</td></tr>
<tr valign="top"><td><code>direction</code></td>
<td>
"x" or "y", indicating which direction points should
be moved to accomplish spacine.</td></tr>
</table>
<h3>Details</h3>
<p>
In an x-y plot where at least one variable has discrete levels several
points may be plotted at or very near the same coordonates.
This makes it difficult to guage the number of points in a specific
region. A common method of resolving this problem is to 'jitter' the
points by adding random noise.
</p>
<p>
This function takes a different approach to the same problem.
</p>
<p>
When there are two or more points with the same (x,y) value (or
within x+-s[1] and x+-s[2]), it spaces these out in the x direction
so that the points are separated by at least distance s.
</p>
<p>
Another method for dealing with overploting is available in the
<code><a href="../../graphics/html/sunflowerplot.html">sunflowerplot</a></code> function.
</p>
<h3>Value</h3>
<p>
list with two components
</p>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
(modified) x location for each input point</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
y location of each input point</td></tr>
</table>
<h3>Author(s)</h3>
<p>
Gregory R. Warnes <a href="mailto:warnes@bst.rochester.edu">warnes@bst.rochester.edu</a>
</p>
<h3>See Also</h3>
<p>
<code><a href="../../base/html/jitter.html">jitter</a></code>, <code>link</code>[base]{sunflowerplot}
</p>
<h3>Examples</h3>
<pre>
x <- rep(1:5, 10)
y <- round(rnorm(length(x),x))
prepar <- par("mfrow")
par(mfrow=c(1,3))
# standard x-y plot: noverlapping points are hidden
plot(x,y)
title("Standard Plot")
# 'spaced' plot: overlapping points are spread out and visible
plot(space(x,y))
title("Plot with 'space'")
# 'spaced' plot: overlapping points are spread out along y and visible
plot(space(x,y, direction='y'))
title("Plot with 'space', direction='y' ")
# 'sunflower' plot, another approach, overlapping points are
# indicated via petals
sunflowerplot(x,y)
title("Sunflower Plot")
par(mfrow=prepar)
</pre>
<hr><div align="center">[Package <em>gplots</em> version 2.3.2 <a href="00Index.html">Index]</a></div>
</body></html>