
Plot and Analyze Coldwave Events
Source:R/sus_climate_plot_coldwaves.R
sus_climate_plot_coldwaves.RdVisualizes and analyzes the results from sus_climate_compute_coldwaves().
Provides multiple visualization types including a Gantt-style timeline of
events, a calendar heatmap, an intensity-vs-duration scatter plot, and an
annual trend bar chart.
Usage
sus_climate_plot_coldwaves(
cw_result,
type = c("timeline", "calendar", "intensity", "trend"),
station_code = NULL,
method = NULL,
year = NULL,
interactive = TRUE,
color_palette = "npg",
lang = "pt",
save_plot = NULL
)Arguments
- cw_result
List. The output from
sus_climate_compute_coldwaves().- type
Character. Type of plot to generate:
"timeline": Gantt-style timeline of coldwave events."calendar": Calendar heatmap showing days with coldwaves."intensity": Scatter plot of duration vs. coldest temperature."trend": Bar chart of number of events per year.
- station_code
Character. Optional. Filter by a specific station code.
- method
Character. Optional. Filter by a specific method (e.g.,
"EHF","INMET").- year
Numeric. Optional. Filter by a specific year (useful for calendar plots).
- interactive
Logical. If
TRUE, returns an interactive Plotly chart. IfFALSE, returns a static ggplot2 chart. Default isTRUE.- color_palette
Character. Name of the ggsci palette to use. Default is
"npg". Blue tones are extracted for cold-event emphasis.- lang
Character. Language for labels:
"pt"(default),"en","es".- save_plot
Character. Optional file path to save the plot (e.g.,
"plot.html"or"plot.png").
Examples
if (FALSE) { # \dontrun{
cw <- df_indicators |> sus_climate_compute_coldwaves(method = c("WHO", "EHF"))
sus_climate_plot_coldwaves(cw, type = "timeline", lang = "pt")
sus_climate_plot_coldwaves(cw, type = "trend", interactive = FALSE)
} # }