Skip to contents

Creates time series plots of species occurrences or species range sizes, with an optional smoothed trendline, and visualizes uncertainty.

Usage

plot_species_ts(
  x,
  species = NULL,
  y_label_default = NULL,
  auto_title = NULL,
  title = "auto",
  min_year = NULL,
  max_year = NULL,
  smoothed_trend = TRUE,
  linecolour = NULL,
  trendlinecolour = NULL,
  envelopecolour = NULL,
  single_plot = TRUE,
  x_label = NULL,
  y_label = NULL,
  x_breaks = 10,
  y_breaks = 6,
  suppress_y = FALSE,
  gridoff = FALSE,
  title_wrap_length = 60
)

Arguments

x

An 'indicator_ts' object containing time series of indicator values matched to species names and/or taxon keys.

species

Species you want to map occurrences for. Can be either numerical taxonKeys or species names. Partial species names can be used (the function will try to match them).

y_label_default

Default label for the y-axis, provided by an appropriate S3 method (if calling the function manually, leave as NULL).

auto_title

Text for automatic title generation, provided by an appropriate S3 method (if calling the function manually, leave as NULL).

title

Plot title. Replace "auto" with your own title if you want a custom title or if calling the function manually.

min_year

(Optional) Earliest year to include in the plot.

max_year

(Optional) Latest year to include in the plot.

smoothed_trend

If TRUE, plot a smoothed trendline.

linecolour

(Optional) Colour for the indicator line. Default is darkorange.

trendlinecolour

(Optional) Colour for the smoothed trendline. Default is blue.

envelopecolour

(Optional) Colour for the uncertainty envelope. Default is lightsteelblue.

single_plot

By default all species occurrence time series will be combined into a single multi-panel plot. Set this to FALSE to plot each species separately.

x_label

Label for the x-axis.

y_label

Label for the y-axis.

x_breaks

Integer giving desired number of breaks for x axis. (May not return exactly the number requested.)

y_breaks

Integer giving desired number of breaks for y axis. (May not return exactly the number requested.)

suppress_y

If TRUE, suppresses y-axis labels.

gridoff

If TRUE, hides gridlines.

title_wrap_length

Maximum title length before wrapping to a new line.

Value

A ggplot object representing species range or occurrence time series plot(s). Can be customized using ggplot2 functions.

Examples

spec_occ_ts_mammals_denmark <- spec_occ_ts(example_cube_1,
                                        level = "country",
                                        region = "Denmark")
# default colours:
plot_species_ts(spec_occ_ts_mammals_denmark, c(2440728, 4265185))


# custom colours:
plot_species_ts(spec_occ_ts_mammals_denmark, c(2440728, 4265185),
        linecolour = "thistle",
        trendlinecolour = "forestgreen",
        envelopecolour = "lightgreen")