scale_circular: Circular ggplot scales

Description Usage Arguments Details Value Functions Examples

View source: R/plotFunctions.R

Description

Extensions of scale_x_continuous and scale_y_continuous that are useful for circular axes.

Usage

1
2
3
4
5
6
7
scale_circular(units = "degrees", nticks = 4, digits = 0,
  limits = c(0, 2 * pi), scale_function = ggplot2::scale_x_continuous,
  ...)

scale_x_circular(...)

scale_y_circular(...)

Arguments

units

The units to display on the axis. See 'Details' for the options.

nticks

The number of ticks to display. Only relevant for continuous scales.

digits

Numeric; The number of digits for continuous scales.

limits

Numeric vector; The limits of the plot. Must two numbers that are 2*pi apart.

scale_function

The scale function from ggplot to use. Either scale_x_continuous or scale_y_continuous. For convenience this option can be circumvented by directly using scale_x_circular or scale_y_circular.

...

Additional arguments to be passed to scale_x_continuous or scale_y_continuous.

Details

Behind the screens, radians will be used, but the plot will display transformed values.

The continuous transformations are "radians", "degrees" and "hours". For these, nticks and digits can be set.

The categorical transformations are "cardinal", which prints character labels of the directions (left, right, up, down), and "compass", which prints compass directions (North, South, East, West). Both of these assume the circular data starts on the right and moves counterclockwise. If not, appropriate transformations must first be taken, or the labels will be nonsensical.

Two additional labels are "texpi" and "texnegpi", which print nice labels for TeX to interpret starting at 0 and -pi respectively. This is useful if TikZ is used.

Value

An object of type ScaleContinuousPosition that can be added to any existing ggplot.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
p <- plot_batmixfit(params = cbind(mu = c(-pi/2, 0, pi/2, pi), kp = 4,
                              lam = c(-.9, .2, .8, 0), alph = .25))

p + scale_x_circular(units = "compass")
p + scale_x_circular(units = "compass", limits = c(-1, 2*pi - 1))

p + scale_x_circular(units = "cardinal")

p + scale_x_circular(units = "texpi")
p + scale_x_circular(units = "texnegpi")

p + scale_x_circular(units = "hours", nticks = 24)

keesmulder/flexcircmix documentation built on May 29, 2019, 3:02 a.m.