lifeTable_plot: Age-Stage Survival Rate Curves

View source: R/lifetable_plot.R

lifeTable_plotR Documentation

Age-Stage Survival Rate Curves

Description

Draws the age-stage survival rate s(x,j) of every developmental stage (including the female and male adults) against age in days, in the style of the classical TWOSEX-MSChart plots.

Usage

lifeTable_plot(
  lt,
  sxj = NULL,
  title = NULL,
  x_title = "Age(days)",
  y_title = "Age-Stage Survival Rate(Sxj)",
  legend_labels = NULL,
  dpi = 300
)

Arguments

lt

A life_table object returned by lifeTable_read.

sxj

Optional; the result of calc_sxj. Supplying it avoids recomputing the age-stage survival rates.

title

Character; plot title. Defaults to the name of the csv file.

x_title

Character; x axis title (default "Age(days)").

y_title

Character; y axis title (default "Age-Stage Survival Rate(Sxj)").

legend_labels

Character vector; legend labels, one per stage (immature stages plus Female and Male), e.g. c("Egg", "1st instar", "Pupa", "Female", "Male"). NULL (default) uses the stage names of the data.

dpi

Numeric; resolution (default 300). Only influences the scaling of the graphical elements (title, axis labels, legend), so that the plot looks identical at 300 and 600 dpi.

Details

To keep the figure clean, each stage is drawn only over the age window in which it actually occurs (extended by two days on both sides). Immature stages are drawn as coloured dots connected by a thin line; females are grey and males black, both with diamond points. By default all text of the figure is in English; title, axis titles and legend labels can be customised.

The text sizes are calibrated for being drawn while 'showtext' is active at its default internal dpi (96); lifeTable_export takes care of this when exporting. If you save the plot yourself, switch 'showtext' on around the ggsave call, otherwise the text comes out about 300/96 times too large.

Value

A ggplot object that can be customised further or saved with ggsave.

See Also

calc_sxj, lifeTable_export

Examples

f <- system.file("extdata", "lifetable_example.csv", package = "insectecol")
p <- lifeTable_plot(lifeTable_read(f))

insectecol documentation built on Oct. 5, 2026, 5:08 p.m.