rose: Rose Diagram

View source: R/rose.R

roseR Documentation

Rose Diagram

Description

Plots a rose diagram (rose of directions), the analogue of a histogram or density plot for angular data.

Usage

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)

Arguments

x

Data to be plotted. A numeric vector containing angles, or a histogram object containing a histogram of angular values, or a density object containing a smooth density estimate for angular data, or an fv object giving a function of an angular argument.

breaks, nclass

Arguments passed to hist to determine the histogram breakpoints. Note that nclass is the number of breakpoints, so that the number of histogram bins is nclass-1.

...

Additional arguments passed to polygon controlling the appearance of the plot (or passed to hist to control the calculation and plotting of the histogram).

unit

The unit in which the angles are expressed. Character string (partially matched).

fullcircle

The period (the value of x that corresponds to one full circle). Required if unit="other" and optional otherwise.

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 ("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. The default is to measure angles anti-clockwise from the horizontal axis (East direction) if unit="degree" or unit="radian" or unit="other", and to measure angles clockwise from top (North direction) if unit="hour" or unit="minute".

clockwise

Logical value indicating whether angles increase in the clockwise direction (clockwise=TRUE) or anti-clockwise, counter-clockwise direction (clockwise=FALSE). The default is clockwise=TRUE if unit="hour" or unit="minute", and clockwise=FALSE otherwise.

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 x.

main

Optional main title for the plot.

fmla

Optional. A formula specifying the curves that should be plotted. This formula is interpreted as described in the help for plot.fv.

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 "red", or an integer that refers to a colour in the standard palette, or a string containing six-letter hexadecimal codes like "#F0A0FF".

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 do.ticks=FALSE to suppress tick marks.

add

Logical value specifying whether the graphics should be added to the existing plot (add=TRUE) or should be drawn on a new plot (add=FALSE, the default).

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.

Details

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.

Value

(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.

Square root transformation

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).

Author(s)

\spatstatAuthors

See Also

fv, hist, circdensity, density.default.

Examples

  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)

spatstat.explore documentation built on May 24, 2026, 9:07 a.m.