| rose | R Documentation |
Plots a rose diagram (rose of directions), the analogue of a histogram or density plot for angular data.
rose(x, ...)
## Default S3 method:
rose(x, breaks = NULL, ...,
weights=NULL,
nclass = NULL,
unit = c("degree", "radian", "hour", "minute", "other"),
fullcircle = NULL,
start=NULL, clockwise=NULL,
root=FALSE,
main, add=FALSE)
## S3 method for class 'histogram'
rose(x, ...,
unit = c("degree", "radian", "hour", "minute", "other"),
fullcircle = NULL,
start=NULL, clockwise=NULL,
root=FALSE,
main, col="lightgray", labels=TRUE, at=NULL,
add=FALSE, do.plot=TRUE,
do.circle=!add, do.rings=!add, do.ticks=!add)
## S3 method for class 'density'
rose(x, ...,
unit = c("degree", "radian", "hour", "minute", "other"),
fullcircle = NULL,
start=NULL, clockwise=NULL,
root=FALSE,
main, labels=TRUE, at=NULL,
add=FALSE, do.plot=TRUE,
do.circle=!add, do.rings=!add, do.ticks=!add)
## S3 method for class 'fv'
rose(x, ..., fmla = NULL,
unit = c("degree", "radian", "hour", "minute", "other"),
fullcircle = NULL,
start=NULL, clockwise=NULL,
root=FALSE,
main, labels=TRUE, at=NULL,
add=FALSE, do.plot=TRUE,
do.circle=!add, do.rings=!add, do.ticks = !add)
x |
Data to be plotted.
A numeric vector containing angles,
or a |
breaks, nclass |
Arguments passed to |
... |
Additional arguments passed to |
unit |
The unit in which the angles are expressed. Character string (partially matched). |
fullcircle |
The period (the value of |
start |
The starting direction for measurement of angles,
that is, the spatial direction which corresponds to a measured angle
of zero. Either a character string giving a compass direction
( |
clockwise |
Logical value indicating whether angles increase in the clockwise
direction ( |
root |
Logical value specifying whether to apply the square root to the histogram heights or curve heights. |
weights |
Optional vector of numeric weights associated with |
main |
Optional main title for the plot. |
fmla |
Optional. A |
col |
Fill colour for the histogram polygons.
A colour value, or a vector of colour values assigning different
colours to each polygon (recycled to the required length).
A colour value can be the string name of a colour
like |
labels |
Either a logical value indicating whether to plot labels next to the tick marks, or a vector of labels for the tick marks. |
at |
Optional vector of angles at which tick marks should be plotted.
Set |
add |
Logical value specifying whether the graphics should be added to
the existing plot ( |
do.plot |
Logical value indicating whether to really perform the plot. |
do.circle |
Logical value indicating whether to draw a circle outside the rose diagram. |
do.rings |
Logical value indicating whether to draw concentric rings for scale inside the plot. |
do.ticks |
Logical value indicating whether to plot tick marks on the outer circle. |
A rose diagram or rose of directions is the analogue of a histogram or bar chart for data which represent angles in two dimensions. The bars of the bar chart are replaced by circular sectors in the rose diagram.
The function rose is generic, with a default method
for numeric data, and methods for histograms and function tables.
If x is a numeric vector, it must contain angular values
in the range 0 to 360 (if unit="degree")
or 0 to 2 * pi (if unit="radian")
or 0 to 24 (if unit="hour")
or 0 to 60 (if unit="minute")
or 0 to fullcircle (if unit="other").
For data expressed in hours but in a 12-hour day,
use unit="hour" and fullcircle=12.
A histogram of the data will first be computed (without plotting) using
hist. Then the rose diagram of this histogram
will be plotted by rose.histogram.
If x is an object of class "histogram" produced by
the function hist, representing the histogram
of angular data, then the rose diagram of the counts
in this histogram object will be plotted. To plot probabilities
instead of counts, set probability=TRUE or
freq=FALSE.
If x is an object of class "density" produced by
circdensity or density.default,
representing a kernel smoothed probability density estimate of angular data,
then the rose diagram of the density estimate will be plotted.
If x is a function value table (object of class "fv")
then the argument of the function will be interpreted as an angle,
and the value of the function will be interpreted as the radius.
The arguments start and clockwise determine how angles
are plotted.
start is the spatial direction which corresponds to a measured angle
of zero. It may be either a character string giving a compass direction
("N" for north, "S" for south, "E" for east,
or "W" for west) or a number giving the angle from the
the horizontal (East) axis to the starting direction. For example,
if unit="degree" and clockwise=FALSE,
then start=90 and start="N" are equivalent.
clockwise is a logical value indicating
whether angles increase in the clockwise
direction (clockwise=TRUE) or anti-clockwise,
counter-clockwise direction (clockwise=FALSE).
The default values of start and clockwise
depend on unit:
If unit="degree" or unit="radian" or unit="other",
by default the angles are interpreted using the mathematical convention
where the zero angle is the horizontal x axis, and angles
increase anti-clockwise. The default values
are start=0 and clockwise=FALSE.
If unit="hour" or unit="minute",
by default the angles are interpreted using the usual clock convention
where the zero angle is the vertical y axis,
and angles increase clockwise.
The default values are start="N" and clockwise=TRUE.
Other conventions can be specified
using the arguments start and clockwise.
Tick marks are drawn around the outer circle if do.ticks=TRUE.
The angular positions of the tick marks are determined
by the argument at (in the same units as x).
Corresponding labels are drawn at the tick marks if
labels=TRUE (the default), and are not drawn if
labels=FALSE. Alternatively labels can be a vector
of labels (character strings, expressions etc) to be plotted at the
tick marks.
If at is missing and labels is a vector,
the tick marks will be equally spaced,
with the number of tick marks equal to the length of labels.
If at and labels are both missing,
there is a sensible default for the tick marks and their labels.
(Invisibly) A window (class "owin") containing the plotted
region. The result also has attribute "R" giving the radius of
the outer circle of the plot, and attribute "rings" giving the
radii of the concentric scale rings. For rose.default and
rose.histogram, the result also has attribute
"histogram" giving the histogram. The attributes
"R", "rings" and "histogram" are the values
calculated before any transformation is applied.
By default, the radial coordinates drawn
in the rose diagram are proportional to the histogram counts,
histogram densities or function values in x. Since the
area of a circular sector is proportional to the square of its
radius, this means that the areas of the sectors drawn in the rose
diagram are proportional to the squares of the histogram counts or
function values.
If root=TRUE, the histogram counts, histogram densities
or function values in x are first transformed by taking the square
root before the rose diagram is drawn. This ensures that
the areas are proportional to the histogram counts or densities
or the function values. The square root transform is also the
variance-stabilising transformation for the Poisson distribution
(so that if root=TRUE, the sampling variability is
approximately equal for each sector in the rose diagram).
fv, hist,
circdensity,
density.default.
ang <- runif(200, max=360)
rose(ang)
rose(ang, col=c("grey", "lightgrey"), start="N", clockwise=TRUE, root=TRUE)
## hours in a 12-hour day
hrs <- runif(200, max=12)
## plot histogram of probability densities
## annotate as a clock face
Nbars <- 30
rose(hrs, unit="h", fullcircle=12,
probability=TRUE,
labels=as.roman(c(12, 1:11)),
nclass=Nbars+1, col=rainbow(Nbars))
## add kernel estimate of probability density
hd <- circdensity(hrs, unit="h", fullcircle=12, adjust=0.5)
rose(hd, add=TRUE,
border="blue", lwd=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.