Package 'OptirrigVIEW'

Title: Visualization Tools for Optirrig Outputs and Tabular Data
Description: A visualization package for Optirrig outputs and generic tabular data. It provides a small plotting core built around ggplot2 to normalize heterogeneous inputs, build reusable graphics, and optionally compose multi-panel views for Optirrig workflows.
Authors: Florian Ricquier [aut, cre] (ORCID: <https://orcid.org/0000-0002-6595-7984>), Kevin Bosirany Orlando [aut] (ORCID: <https://orcid.org/0009-0009-2784-3108>), Bruno Cheviron [aut], UMR G-Eau Aqua Department INRAE Montpellier Team Optimiste [aut]
Maintainer: Florian Ricquier <[email protected]>
License: AGPL (>= 3)
Version: 0.1.0
Built: 2026-05-23 09:08:35 UTC
Source: https://forge.inrae.fr/OptirrigHIVE/OptirrigVIEW

Help Index


Optirrig palette

Description

Default color palette used by OptirrigVIEW.

Usage

optirrig_palette

optirrig_view_palette

Format

An object of class character of length 6.

An object of class character of length 6.

Value

A named character vector of hex colors.


Build an OptirrigVIEW graph specification

Description

plot_vars() defines one independent graph before panel composition. Use the returned object inside plot(x, options = list(plots = ...)), then organize the panel layout separately with layout.

Usage

plot_vars(var_1 = NULL, var_2, var_3 = NULL, options = NULL)

Arguments

var_1

Column used on the x axis. If NULL, reuse the normalized x mapping.

var_2

Primary y specification.

var_3

Optional secondary y specification.

options

Optional list with graph-level options. Supported entries are title, subtitle, x_lab, y_lab, y2_lab, theme, palette, alpha, filter, and plot_args.

Details

var_1 defines the x axis column. var_2 defines the primary y variable(s), and var_3 optionally defines a secondary y axis. var_2 and var_3 accept either a regex string, or a list with entries such as series, regex, values, geom, and label.

Value

An object of class optirrig_view_plot_spec.


Plot method for tabular data

Description

Plot method for tabular data

Usage

## S3 method for class 'data.frame'
plot(x, options = NULL, geom = "line", interactive = FALSE, ...)

Arguments

x

A data frame.

options

Optional OptirrigVIEW plotting options.

geom

Default geometry to draw.

interactive

If TRUE, return a plotly object for single plots.

...

Additional arguments passed to view_data().

Value

A ggplot object, a composed patchwork object, or a plotly object when requested for a single panel.


Plot method for list inputs

Description

Plot method for list inputs

Usage

## S3 method for class 'list'
plot(x, options = NULL, geom = "line", interactive = FALSE, ...)

Arguments

x

A list of tables, matrices, or nested Optirrig-like outputs.

options

Optional OptirrigVIEW plotting options.

geom

Default geometry to draw.

interactive

If TRUE, return a plotly object for single plots.

...

Additional arguments passed to view_data().

Value

A ggplot object, a composed patchwork object, or a plotly object when requested for a single panel.


Plot method for matrix data

Description

Plot method for matrix data

Usage

## S3 method for class 'matrix'
plot(x, options = NULL, geom = "line", interactive = FALSE, ...)

Arguments

x

A matrix.

options

Optional OptirrigVIEW plotting options.

geom

Default geometry to draw.

interactive

If TRUE, return a plotly object for single plots.

...

Additional arguments passed to view_data().

Value

A ggplot object, a composed patchwork object, or a plotly object when requested for a single panel.


Plot method for a single Optirrig model output

Description

Plot method for a single Optirrig model output

Usage

## S3 method for class 'model_output'
plot(x, y = NULL, obs = NULL, options = NULL, ...)

Arguments

x

A model_output object, typically one element of OptirrigCORE::run_model() output.

y

Optional shortcut passed to plot.model_outputs().

obs

Optional observed data passed to plot.model_outputs().

options

Optional list passed to plot.model_outputs().

...

Additional arguments passed to plot.model_outputs().

Value

A ggplot object, a composed patchwork object, or a plotly object when requested for a single panel.


Plot method for Optirrig model outputs

Description

This method lets plot() normalize model_outputs internally. It supports direct graph definitions with x, y, and optional y_bis, so the user does not need to call view_data() for each panel.

Usage

## S3 method for class 'model_outputs'
plot(
  x,
  y = NULL,
  obs = NULL,
  geom = "line",
  interactive = FALSE,
  options = NULL,
  ...
)

Arguments

x

A model_outputs object, typically returned by OptirrigCORE::run_model().

y

Optional shortcut. A character value is treated as options$y; otherwise it is treated as observed data for compatibility with plot(x, y, ...).

obs

Optional observed data. Use a named list such as list(LAI = data.frame(Date = ..., LAI = ...)), or one data frame with matching variable columns.

geom

Default geometry to draw.

interactive

If TRUE, return a plotly object for single plots.

options

Optional list. Supported top-level entries are x, y, y_bis (or y2), geom, geom_bis, values, regex, filter, plots, layout, theme, title, subtitle, plot_args, and guides. Compatibility aliases from OptirrigTOOLS::plot_outputs() include outs, runs_id, run_prefix, pos, main, time_opt, yield_var, ratio, palette, ylim, and legend_position. When x is supplied, it is treated as the name of the output column to use on the x axis and overrides the time_opt defaults for axis labeling. When plots is supplied, each graph can be defined as a string "LAI" or as a list with x, y, optional y_bis, and graph options such as geom, title, x_lab, y_lab, y2_lab, theme, palette, alpha, and filter.

...

Additional arguments passed to view_plot().

Value

A ggplot object, or a plotly object when interactive = TRUE.


Plot method for normalized OptirrigVIEW data

Description

Plot method for normalized OptirrigVIEW data

Usage

## S3 method for class 'optirrig_view_data'
plot(x, geom = "line", interactive = FALSE, options = NULL, ...)

Arguments

x

An optirrig_view_data object.

geom

Geometry to draw.

interactive

If TRUE, return a plotly object.

options

Optional list used to recover the historical plot(x, options = list(...)) style. Supported entries are: plots, layout, theme, title, subtitle, plot_args, and guides. plots must be a named list of objects created with plot_vars(). Graph-level filter functions can be passed inside plot_vars(..., options = list(filter = ...)). Legacy panels definitions are still accepted and converted internally.

...

Additional arguments passed to view_plot().

Value

A ggplot object, or a plotly object when interactive = TRUE.


Optirrig ggplot theme

Description

Lightweight theme used by view_plot().

Usage

theme_optirrig(base_size = 12, legend_position = "top")

theme_optirrig_view(base_size = 12, legend_position = "top")

Arguments

base_size

Base font size.

legend_position

Legend position passed to ggplot2::theme().

Value

A ggplot2 theme.


Compose multiple OptirrigVIEW plots

Description

view_compose() combines several named ggplot objects into a single layout. The layout argument accepts the same compact row syntax as the historical Optirrig plotting helpers, for example "graph1 | graph2 / graph3 | graph4".

Usage

view_compose(
  plots,
  layout = NULL,
  title = NULL,
  subtitle = NULL,
  theme = NULL,
  guides = "collect"
)

Arguments

plots

Named list of ggplot objects.

layout

Optional layout description. Use | to place plots on the same row and / to stack rows.

title, subtitle

Optional global annotation.

theme

Optional theme object, or a function returning one, applied to each plot before composition.

guides

Guide collection mode passed to patchwork::plot_layout().

Value

A ggplot object for a single plot, or a composed patchwork object.


Normalize data for OptirrigVIEW plots

Description

view_data() converts several common input shapes into a plotting table with stored column mappings. This object can then be passed directly to view_plot() or plot().

Usage

view_data(x, ...)

## S3 method for class 'data.frame'
view_data(
  x,
  x_var = NULL,
  y_var = NULL,
  value_vars = NULL,
  series = NULL,
  facet = NULL,
  ymin = NULL,
  ymax = NULL,
  group = NULL,
  names_to = "series",
  values_to = "value",
  drop_na = TRUE,
  ...
)

## S3 method for class 'list'
view_data(
  x,
  x_var = NULL,
  y_var = NULL,
  value_vars = NULL,
  series = NULL,
  facet = NULL,
  ymin = NULL,
  ymax = NULL,
  group = NULL,
  names_to = "series",
  values_to = "value",
  drop_na = TRUE,
  ...
)

## S3 method for class 'matrix'
view_data(
  x,
  x_var = NULL,
  y_var = NULL,
  value_vars = NULL,
  series = NULL,
  facet = NULL,
  ymin = NULL,
  ymax = NULL,
  group = NULL,
  names_to = "series",
  values_to = "value",
  drop_na = TRUE,
  ...
)

## Default S3 method:
view_data(x, ...)

## S3 method for class 'optirrig_view_data'
view_data(x, ...)

Arguments

x

Object to normalize.

...

Unused.

x_var

Column used on the x axis.

y_var

Column used on the y axis when data is already long.

value_vars

Columns to pivot to a long value column.

series

Optional grouping column.

facet

Optional faceting column.

ymin, ymax

Optional lower and upper bound columns, mainly for ribbons.

group

Optional grouping column passed to geoms.

names_to

Name of the column created by tidyr::pivot_longer().

values_to

Name of the value column created by tidyr::pivot_longer().

drop_na

If TRUE, remove rows with missing plotted values.

Value

An object of class optirrig_view_data.


Build an OptirrigVIEW plot

Description

view_plot() accepts either raw data or the normalized output of view_data(). The function keeps the plotting API intentionally small and handles the most common plot types used across Optirrig packages.

Usage

view_plot(
  x,
  geom = c("line", "point", "col", "boxplot", "ribbon", "area"),
  x_var = NULL,
  y_var = NULL,
  value_vars = NULL,
  series = NULL,
  facet = NULL,
  ymin = NULL,
  ymax = NULL,
  group = NULL,
  names_to = "series",
  values_to = "value",
  drop_na = TRUE,
  title = NULL,
  subtitle = NULL,
  x_lab = NULL,
  y_lab = NULL,
  palette = optirrig_palette,
  series_values = NULL,
  scales = "free_y",
  alpha = NULL,
  interactive = FALSE,
  tooltip = NULL,
  ...
)

Arguments

x

Object to plot.

geom

Geometry to draw.

x_var, y_var, value_vars, series, facet, ymin, ymax, group, names_to, values_to, drop_na

Passed to view_data() when x is not already normalized.

title, subtitle

Plot labels.

x_lab, y_lab

Axis labels.

palette

Color palette used for grouped plots.

series_values

Optional complete set of series values to keep in the legend, even when some series are absent from one panel.

scales

Facet scales passed to ggplot2::facet_wrap().

alpha

Geom transparency.

interactive

If TRUE, return a plotly object.

tooltip

Optional tooltip vector passed to plotly::ggplotly().

...

Unused.

Value

A ggplot object, or a plotly object when interactive = TRUE.


Convert a ggplot to plotly

Description

Convert a ggplot to plotly

Usage

view_plotly(x, tooltip = NULL)

Arguments

x

A ggplot object.

tooltip

Optional tooltip vector forwarded to plotly::ggplotly().

Value

A plotly object.