This geom allows you to draw the hypotrochoid curve. A hypotrochoid is a curve traced by a point attached to a circle of radius r_min rolling around the inside of a fixed circle of radius r_max, where the point is at a distance h from the center of the interior circle.

stat_hypotrochoid(mapping = NULL, data = NULL, geom = "hypotrochoid",
  position = "identity", n_points = 360, na.rm = FALSE,
  show.legend = NA, inherit.aes = TRUE, ...)

geom_hypotrochoid(mapping = NULL, data = NULL, stat = "hypotrochoid",
  position = "identity", n_points = 360, na.rm = FALSE,
  show.legend = NA, inherit.aes = TRUE, ...)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data.

geom

The geometric object to use display the data

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

n_points

The number of points to sample along the curve.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

stat

The statistical transformation to use on the data for this layer, as a string.

Details

To unscale the curve, please set xscale and yscale to abs(r_max - r_min) + h.

The curve follows the the parameterized form

$$x = (r_max - r_min) cos(\theta) + h * cos(\frac{r_max - r_min}{r_min} \theta)$$ $$x = (r_max - r_min) sin(\theta) + h * sin(\frac{r_max - r_min}{r_min} \theta)$$

these curves are closed when the radion \(a / b\) is rational. delta have been scaled to be in the interval [0, 1].

Aesthetics

geom_arc understand the following aesthetics (required aesthetics are in bold):

- **r_max** - **r_min** - h - x0 - y0 - xscale - yscale - rotation - color - fill - size - linetype - alpha - lineend

Computed variables

x, y

The coordinates for the points along the rose curve

References

https://en.wikipedia.org/wiki/Hypocycloid http://xahlee.info/SpecialPlaneCurves_dir/Hypotrochoid_dir/hypotrochoid.html

See also

[geom_epitrochoid()]

Examples

# When h is missing a hypocycloid is generated ggplot() + geom_hypotrochoid(aes(r_max = 4, r_min = 1))
ggplot() + geom_hypotrochoid(aes(r_max = 8, r_min = 1))
ggplot() + geom_hypotrochoid(aes(r_max = c(4, 6, 8), r_min = 1))
# specifying h ggplot() + geom_hypotrochoid(aes(r_max = 4, r_min = 9, h = 4))
ggplot() + geom_hypotrochoid(aes(r_max = 4, r_min = 3, h = 20 / 13))
# changing rotation ggplot() + geom_hypotrochoid(aes(r_max = 4, r_min = 1, rotation = pi / 4))
# When things go wild ggplot(expand.grid(seq(4, 20, by = 2), c(1, 3, 5, 9))) + geom_hypotrochoid(aes(r_max = Var1, r_min = Var2, color = Var1, xscale = abs(Var1 - Var2) + Var2, yscale = abs(Var1 - Var2) + Var2)) + coord_fixed() + theme_minimal() + scale_color_viridis_c(option = "B") + guides(color = "none") + facet_wrap(~ Var2)