Plot flow series with state transitions
plot_state_machine.RdVisualises a time series of flow alongside state transitions produced
by run_state_machine. The function overlays the flow signal
with vertical lines marking transition points and optional annotations
for detected states.
Arguments
- time
A vector of timestamps (POSIXct or convertible).
- flow
Numeric vector of flow values.
- transitions
A data frame returned by
run_state_machine(), containing `time` and `state` columns.- show_labels
Logical. If `TRUE`, state labels are shown at transition points. Default is `TRUE`.
- line_color
Color for the flow time series. Default `"black"`.
Details
The plot shows:
the flow time series as a line
vertical dashed lines indicating state transitions
optional labels indicating the new state at each transition
This function is designed for use in pkgdown vignettes and supports further customisation via standard ggplot2 layers.
Examples
if (FALSE) { # \dontrun{
transitions <- run_state_machine(time, flow, params)
plot_state_machine(time, flow, transitions)
} # }