| 42333 |
ripley |
1 |
% File src/library/graphics/man/sunflowerplot.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 74265 |
hornik |
3 |
% Copyright 1995-2018 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{sunflowerplot}
|
| 56186 |
murdoch |
7 |
\alias{sunflowerplot}
|
| 55219 |
ripley |
8 |
\alias{sunflowerplot.default}
|
|
|
9 |
\alias{sunflowerplot.formula}
|
| 27442 |
ripley |
10 |
\title{Produce a Sunflower Scatter Plot}
|
|
|
11 |
\description{
|
| 42961 |
ripley |
12 |
Multiple points are plotted as \sQuote{sunflowers} with multiple leaves
|
| 55219 |
ripley |
13 |
(\sQuote{petals}) such that overplotting is visualized instead of
|
|
|
14 |
accidental and invisible.
|
| 27442 |
ripley |
15 |
}
|
|
|
16 |
\usage{
|
| 55219 |
ripley |
17 |
sunflowerplot(x, \dots)
|
|
|
18 |
|
|
|
19 |
\method{sunflowerplot}{default}(x, y = NULL, number, log = "", digits = 6,
|
| 30915 |
ripley |
20 |
xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL,
|
|
|
21 |
add = FALSE, rotate = FALSE,
|
| 36816 |
ripley |
22 |
pch = 16, cex = 0.8, cex.fact = 1.5,
|
|
|
23 |
col = par("col"), bg = NA, size = 1/8, seg.col = 2,
|
|
|
24 |
seg.lwd = 1.5, \dots)
|
| 55219 |
ripley |
25 |
|
| 55392 |
ripley |
26 |
\method{sunflowerplot}{formula}(formula, data = NULL, xlab = NULL, ylab = NULL, \dots,
|
| 55219 |
ripley |
27 |
subset, na.action = NULL)
|
| 27442 |
ripley |
28 |
}
|
|
|
29 |
\arguments{
|
|
|
30 |
\item{x}{numeric vector of \code{x}-coordinates of length \code{n},
|
|
|
31 |
say, or another valid plotting structure, as for
|
|
|
32 |
\code{\link{plot.default}}, see also \code{\link{xy.coords}}.}
|
|
|
33 |
\item{y}{numeric vector of \code{y}-coordinates of length \code{n}.}
|
|
|
34 |
\item{number}{integer vector of length \code{n}. \code{number[i]} = number
|
| 61168 |
ripley |
35 |
of replicates for \code{(x[i], y[i])}, may be 0.\cr
|
| 41057 |
maechler |
36 |
Default (\code{missing(number)}): compute the exact multiplicity of
|
| 61168 |
ripley |
37 |
the points \code{x[], y[]}, via
|
| 49470 |
ripley |
38 |
\code{\link{xyTable}()}.}
|
| 27442 |
ripley |
39 |
\item{log}{character indicating log coordinate scale, see
|
|
|
40 |
\code{\link{plot.default}}.}
|
|
|
41 |
\item{digits}{when \code{number} is computed (i.e., not specified),
|
|
|
42 |
\code{x} and \code{y} are rounded to \code{digits} significant
|
| 27625 |
ripley |
43 |
digits before multiplicities are computed.}
|
| 61168 |
ripley |
44 |
\item{xlab, ylab}{character label for x-, or y-axis, respectively.}
|
|
|
45 |
\item{xlim, ylim}{\code{numeric(2)} limiting the extents of the x-,
|
| 27442 |
ripley |
46 |
or y-axis.}
|
|
|
47 |
\item{add}{logical; should the plot be added on a previous one ?
|
|
|
48 |
Default is \code{FALSE}.}
|
|
|
49 |
\item{rotate}{logical; if \code{TRUE}, randomly rotate the
|
|
|
50 |
sunflowers (preventing artefacts).}
|
|
|
51 |
\item{pch}{plotting character to be used for points
|
|
|
52 |
(\code{number[i]==1}) and center of sunflowers.}
|
|
|
53 |
\item{cex}{numeric; character size expansion of center points
|
|
|
54 |
(s. \code{pch}).}
|
|
|
55 |
\item{cex.fact}{numeric \emph{shrinking} factor to be used for the
|
|
|
56 |
center points \emph{when there are flower leaves},
|
|
|
57 |
i.e., \code{cex / cex.fact} is used for these.}
|
| 32641 |
maechler |
58 |
\item{col, bg}{colors for the plot symbols, passed to
|
|
|
59 |
\code{\link{plot.default}}.}
|
| 27442 |
ripley |
60 |
\item{size}{of sunflower leaves in inches, 1[in] := 2.54[cm].
|
|
|
61 |
Default: 1/8\", approximately 3.2mm.}
|
|
|
62 |
\item{seg.col}{color to be used for the \bold{seg}ments which make the
|
|
|
63 |
sunflowers leaves, see \code{\link{par}(col=)};
|
|
|
64 |
\code{col = "gold"} reminds of real sunflowers.}
|
|
|
65 |
\item{seg.lwd}{numeric; the line width for the leaves' segments.}
|
|
|
66 |
\item{\dots}{further arguments to \code{\link{plot}} [if
|
| 55219 |
ripley |
67 |
\code{add = FALSE}], or to be passed to or from another method.}
|
|
|
68 |
\item{formula}{a \code{\link{formula}}, such as \code{y ~ x}.}
|
|
|
69 |
\item{data}{a data.frame (or list) from which the variables in
|
|
|
70 |
\code{formula} should be taken.}
|
|
|
71 |
\item{subset}{an optional vector specifying a subset of observations
|
|
|
72 |
to be used in the fitting process.}
|
|
|
73 |
\item{na.action}{a function which indicates what should happen
|
|
|
74 |
when the data contain \code{NA}s. The default is to ignore case
|
|
|
75 |
with missing values.}
|
| 27442 |
ripley |
76 |
}
|
|
|
77 |
\details{
|
| 55219 |
ripley |
78 |
This is a generic function with default and formula methods.
|
| 61433 |
ripley |
79 |
|
| 55219 |
ripley |
80 |
For \code{number[i] == 1}, a (slightly enlarged) usual plotting symbol
|
|
|
81 |
(\code{pch}) is drawn. For \code{number[i] > 1}, a small plotting
|
|
|
82 |
symbol is drawn and \code{number[i]} equi-angular \sQuote{rays}
|
|
|
83 |
emanate from it.
|
| 27442 |
ripley |
84 |
|
| 55219 |
ripley |
85 |
If \code{rotate = TRUE} and \code{number[i] >= 2}, a random direction
|
| 27442 |
ripley |
86 |
is chosen (instead of the y-axis) for the first ray. The goal is to
|
| 55219 |
ripley |
87 |
\code{\link{jitter}} the orientations of the sunflowers in order to
|
|
|
88 |
prevent artefactual visual impressions.
|
| 27442 |
ripley |
89 |
}
|
|
|
90 |
\section{Side Effects}{
|
| 42961 |
ripley |
91 |
A scatter plot is drawn with \sQuote{sunflowers} as symbols.
|
| 27442 |
ripley |
92 |
}
|
|
|
93 |
\value{
|
|
|
94 |
A list with three components of same length,
|
|
|
95 |
\item{x}{x coordinates}
|
|
|
96 |
\item{y}{y coordinates}
|
|
|
97 |
\item{number}{number}
|
| 41057 |
maechler |
98 |
|
| 49470 |
ripley |
99 |
Use \code{\link{xyTable}()} (from package
|
| 41057 |
maechler |
100 |
\pkg{grDevices}) if you are only interested in this return value.
|
| 27442 |
ripley |
101 |
}
|
|
|
102 |
\references{
|
| 74265 |
hornik |
103 |
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A. (1983).
|
|
|
104 |
\emph{Graphical Methods for Data Analysis}.
|
|
|
105 |
Wadsworth.
|
| 27442 |
ripley |
106 |
|
| 74265 |
hornik |
107 |
Schilling, M. F. and Watkins, A. E. (1994).
|
| 27442 |
ripley |
108 |
A suggestion for sunflower plots.
|
|
|
109 |
\emph{The American Statistician}, \bold{48}, 303--305.
|
| 74265 |
hornik |
110 |
\doi{10.2307/2684839}.
|
| 36222 |
ripley |
111 |
|
| 74265 |
hornik |
112 |
Murrell, P. (2005).
|
|
|
113 |
\emph{R Graphics}.
|
|
|
114 |
Chapman & Hall/CRC Press.
|
| 27442 |
ripley |
115 |
}
|
|
|
116 |
\author{
|
|
|
117 |
Andreas Ruckstuhl, Werner Stahel, Martin Maechler, Tim Hesterberg,
|
|
|
118 |
1989--1993. Port to \R by Martin Maechler
|
|
|
119 |
\email{maechler@stat.math.ethz.ch}.
|
|
|
120 |
}
|
| 49470 |
ripley |
121 |
\seealso{\code{\link{density}}, \code{\link{xyTable}}
|
| 41057 |
maechler |
122 |
}
|
| 27442 |
ripley |
123 |
\examples{
|
| 67689 |
ripley |
124 |
require(stats) # for rnorm
|
| 42304 |
maechler |
125 |
require(grDevices)
|
|
|
126 |
|
| 27442 |
ripley |
127 |
## 'number' is computed automatically:
|
|
|
128 |
sunflowerplot(iris[, 3:4])
|
| 65189 |
hornik |
129 |
## Imitating Chambers et al, p.109, closely:
|
| 61153 |
ripley |
130 |
sunflowerplot(iris[, 3:4], cex = .2, cex.fact = 1, size = .035, seg.lwd = .8)
|
| 55219 |
ripley |
131 |
## or
|
| 61153 |
ripley |
132 |
sunflowerplot(Petal.Width ~ Petal.Length, data = iris,
|
|
|
133 |
cex = .2, cex.fact = 1, size = .035, seg.lwd = .8)
|
| 27442 |
ripley |
134 |
|
| 55219 |
ripley |
135 |
|
| 61168 |
ripley |
136 |
sunflowerplot(x = sort(2*round(rnorm(100))), y = round(rnorm(100), 0),
|
| 32641 |
maechler |
137 |
main = "Sunflower Plot of Rounded N(0,1)")
|
| 42304 |
maechler |
138 |
## Similarly using a "xyTable" argument:
|
| 61168 |
ripley |
139 |
xyT <- xyTable(x = sort(2*round(rnorm(100))), y = round(rnorm(100), 0),
|
| 61153 |
ripley |
140 |
digits = 3)
|
|
|
141 |
utils::str(xyT, vec.len = 20)
|
| 42304 |
maechler |
142 |
sunflowerplot(xyT, main = "2nd Sunflower Plot of Rounded N(0,1)")
|
| 27442 |
ripley |
143 |
|
| 42304 |
maechler |
144 |
## A 'marked point process' {explicit 'number' argument}:
|
| 61168 |
ripley |
145 |
sunflowerplot(rnorm(100), rnorm(100), number = rpois(n = 100, lambda = 2),
|
| 61153 |
ripley |
146 |
main = "Sunflower plot (marked point process)",
|
|
|
147 |
rotate = TRUE, col = "blue4")
|
| 27442 |
ripley |
148 |
}
|
|
|
149 |
\keyword{hplot}
|
|
|
150 |
\keyword{smooth}
|
|
|
151 |
\keyword{nonparametric}
|