Converts a ggplot2 object produced by the mappingAS plot_*
functions (plot_conversion, plot_protection,
plot_timeseries, plot_fire_timeseries) into an
interactive plotly widget. Those functions attach the tidy data and
palette needed, so the widget is built as native plotly (correct
per-segment hover tooltips and in-bar labels) rather than through
ggplotly(). Any other ggplot falls back to ggplotly(). This is
the single place that controls the interactive look across the package and
the Shiny app.
Usage
mas_plotly(p, tooltip = c("fill", "x", "y"), ...)Arguments
- p
A ggplot object (as returned by the
plot_*functions). Any non-ggplot is returned unchanged.- tooltip
Aesthetics passed to
plotly::ggplotly()in the generic fallback (defaultc("fill", "x", "y")).- ...
Reserved for future use.
Examples
if (interactive()) {
occ <- read_occurrences(system.file("extdata", "example_occurrences.csv",
package = "mappingAS"))
res <- assess_species(occ, year = 2024, verbose = FALSE) # reads MapBiomas
mas_plotly(plot_conversion(res))
}
