Select Plot Backends
PowerGraphics.jl supports two plotting backends through Julia package extensions. Load the backend you want before or alongside PowerGraphics:
- CairoMakie (recommended): static, publication-quality plots —
using CairoMakie - PlotlyLight: lightweight interactive HTML plots —
using PlotlyLight
using CairoMakie # or PlotlyLight
using PowerGraphics
using PowerAnalyticsIf neither backend is loaded, PowerGraphics prints a warning at load time and plotting functions throw an ArgumentError when called.
API selects the backend
Choose the function name to choose the backend:
- Unsuffixed functions (e.g.
plot_powerdata,plot_fuel,plot_demand,plot_dataframe) use CairoMakie *_plotlyvariants (e.g.plot_powerdata_plotly,plot_fuel_plotly) use PlotlyLight
# where `gen` is a PowerAnalytics.PowerData from get_generation_data(res)
plot_powerdata(gen) # CairoMakie
plot_powerdata_plotly(gen) # PlotlyLightMutating ! forms (plot_powerdata!, plot_fuel!, …) overlay series onto an existing plot handle from the same backend family.
Saving plots
Use save_plot (or the save / format kwargs on plot calls):
- CairoMakie:
"png","pdf","svg" - PlotlyLight:
"html"(other extensions are written as.htmlwith a warning)
p = plot_fuel(res)
save_plot(p, "fuel.png")
p = plot_fuel_plotly(res)
save_plot(p, "fuel.html")Reports
report (requires Weave.jl plus a plotting backend) builds HTML or PDF summaries from a .jmd template. Choose the plot backend with the backend keyword (CairoMakieBackend() or PlotlyLightBackend()):
using Weave
report(
res,
out_path,
template;
doctype = "md2pdf",
backend = PowerGraphics.CairoMakieBackend(),
)See the Gallery for CairoMakie plot archetypes, Plot styling keywords for shared plot options, and the Public API for function-specific keywords.