geom_colon: Colon Geometry Layer for ggplot2

View source: R/stat_colon.R

geom_colonR Documentation

Colon Geometry Layer for ggplot2

Description

This function defines a custom ggplot2 layer that allows users to plot the colon geometry based on the predefined blueprint. It takes in aesthetics for x, y, and part, and uses the StatColon ggproto object to compute the necessary data for plotting the colon structure. The resulting layer can be used in conjunction with other ggplot2 layers to create detailed visualizations of the colon.

Usage

geom_colon(
  mapping = NULL,
  data = NULL,
  variant = "standard",
  show.legend = NA,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by 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. A function can be created from a formula (e.g. ~ head(.x, 10)).

variant

A character string specifying the variant of the colon blueprint to use.

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. To include legend keys for all levels, even when no data exists, use TRUE. If NA, all levels are shown in legend, but unobserved levels are omitted.

...

Additional parameters passed to the layer, such as fill, color, size, etc.

Details

The geom_colon function creates a layer that can be added to a ggplot2 plot. It requires the aesthetics x, y, and part to be specified, which correspond to the position and the specific part of the colon to be plotted.

The variants can be defined in the colon_variants list, which should contain different blueprints for the colon geometry.

Value

A ggplot2 layer that can be added to a plot to visualize the colon geometry.


ggcolonviz documentation built on Oct. 15, 2026, 5:09 p.m.