add_text: Wrapper to add text to nested loop plot

View source: R/nested_loop.R

add_textR Documentation

Wrapper to add text to nested loop plot

Description

All parameters not explicitly described here are simply passed to geom_text.

Usage

add_text(p, decimals = 2, mapping = NULL, data = NULL, position = "top", ...)

Arguments

p

ggplot2 object, output from nested_loop_plot function.

decimals

Number of decimals to be display if called with default mapping to display labels for each plotted value.

mapping

Aesthethics mapping specification for the text created by aes. This allows to use user-specified data as labels. Passed to geom_text. The mapping must specify the label aesthetic.

data

Specify other data source to use label data from. Must contain information from the data.frame that is plotted and obtained from nested_loop_base_data. Passed to geom_text.

position

Position of the geometry layer, either "bottom" or "top". By default text is added above all other layers in the plot to be unobstructed by other geometries, but by setting position to "bottom", text can also be plotted below other geometries.

Details

Simple wrapper for geom_text to add text to nested loop plot. Useful to e.g. annotate special values.

The most simple, default usage is to add the values of the plots (rounded to two decimals). The plotted values are accessed via the y_coord variable of the data.frame returned from nested_loop_base_data.

More advanced usage and custom labeldata can be introduced to the plots by using the modular functions of this package. See the demo vignette for an example.

Value

A ggplot2 object.

Examples

## Not run: 
# add values with two decimals to plot 
p = add_text(p, aes = aes(labels = round(values, 2)))

## End(Not run)


matherealize/looplot documentation built on Jan. 14, 2024, 2:07 a.m.