Public API Reference

PowerGraphics.label_acronymMethod
label_acronym(
    s::AbstractString
) -> Union{Base.AnnotatedString{String}, String}

Convert CamelCase segments to their uppercase initials, preserving the __ separator.

Example

label_acronym("ActivePowerVariable__HydroDispatch")       # => "APV__HD"
label_acronym("ActivePowerOutVariable__EnergyReservoirStorage")  # => "APOV__ERS"
label_acronym("SomeLabel")                                 # => "SL"
source
PowerGraphics.label_componentMethod
label_component(s::AbstractString) -> Any

Extract the component type (part after __) from a label.

Example

label_component("ActivePowerVariable__HydroDispatch")  # => "HydroDispatch"
label_component("SomeLabel")                            # => "SomeLabel"
source
PowerGraphics.label_first_wordMethod
label_first_word(s::AbstractString) -> Any

Extract the first CamelCase word from the label (ignoring the __ separator structure).

Example

label_first_word("ActivePowerVariable__HydroDispatch")  # => "Active"
label_first_word("HydroDispatch")                        # => "Hydro"
source
PowerGraphics.label_shortMethod
label_short(s::AbstractString) -> Any

Abbreviate the variable prefix (part before __) to its uppercase initials while keeping the full component name (part after __). Labels without __ are returned unchanged. This is the default label_fn.

Example

label_short("ActivePowerVariable__HydroDispatch")             # => "APV: HydroDispatch"
label_short("ActivePowerOutVariable__EnergyReservoirStorage")  # => "APOV: EnergyReservoirStorage"
label_short("SomeLabel")                                       # => "SomeLabel"
source
PowerGraphics.label_truncateMethod
label_truncate(
    n::Int64
) -> PowerGraphics.var"#label_truncate##0#label_truncate##1"{Int64}

Return a label function that truncates labels longer than n characters, appending "…". Can be composed with other label functions such as label_short.

Example

plot_powerdata(gen; label_fn = label_truncate(20))
# "ActivePowerVariable…"

# Compose with label_short:
plot_powerdata(gen; label_fn = s -> label_truncate(15)(label_short(s)))
source
PowerGraphics.label_variableMethod
label_variable(s::AbstractString) -> Any

Extract the variable type (part before __) from a label.

Example

label_variable("ActivePowerVariable__HydroDispatch")  # => "ActivePowerVariable"
label_variable("SomeLabel")                            # => "SomeLabel"
source
PowerGraphics.plot_dataframe!Method
plot_dataframe!(
    p,
    df::DataFrames.DataFrame;
    kwargs...
) -> Any

Plot columns of a DataFrames.DataFrame onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_dataframe)
  • df: wide DataFrames.DataFrame of series to plot
  • time_range: timestamps (DataFrame, Array, or StepRange); omitted when df already has a DateTime column

Keyword Arguments

See also plot_dataframe.

source
PowerGraphics.plot_dataframeMethod
plot_dataframe(df::DataFrames.DataFrame; kwargs...)

Plot columns of a DataFrames.DataFrame as series over time.

Each row is a time period and each column is a trace. If only df is provided, it must contain a DateTime column.

Arguments

  • df: wide DataFrames.DataFrame of series to plot
  • time_range: timestamps (DataFrame, Array, or StepRange); omitted when df already has a DateTime column

Keyword Arguments

Example

# `res` is a solved InfrastructureSystems.Results (e.g. from PowerSimulations)
gen = PowerAnalytics.get_generation_data(res)
df = gen.data[:ActivePowerVariable__ThermalStandard]
plot_dataframe(df, gen.time)

See also plot_dataframe!, plot_powerdata.

source
PowerGraphics.plot_dataframe_plotly!Method
plot_dataframe_plotly!(p, df::DataFrame; kwargs...)
plot_dataframe!(
    p,
    df::DataFrames.DataFrame;
    kwargs...
) -> Any

Plot columns of a DataFrames.DataFrame onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_dataframe)
  • df: wide DataFrames.DataFrame of series to plot
  • time_range: timestamps (DataFrame, Array, or StepRange); omitted when df already has a DateTime column

Keyword Arguments

See also plot_dataframe.

source
PowerGraphics.plot_dataframe_plotlyMethod
plot_dataframe_plotly(df::DataFrame; kwargs...)
plot_dataframe(df::DataFrames.DataFrame; kwargs...)

Plot columns of a DataFrames.DataFrame as series over time.

Each row is a time period and each column is a trace. If only df is provided, it must contain a DateTime column.

Arguments

  • df: wide DataFrames.DataFrame of series to plot
  • time_range: timestamps (DataFrame, Array, or StepRange); omitted when df already has a DateTime column

Keyword Arguments

Example

# `res` is a solved InfrastructureSystems.Results (e.g. from PowerSimulations)
gen = PowerAnalytics.get_generation_data(res)
df = gen.data[:ActivePowerVariable__ThermalStandard]
plot_dataframe(df, gen.time)

See also plot_dataframe!, plot_powerdata.

source
PowerGraphics.plot_demand!Method
plot_demand!(
    p,
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
) -> Any

Plot demand onto an existing plot handle.

Arguments

Keyword Arguments

  • aggregate: "System", "PowerLoad", or "Bus" — aggregate demand by PowerSystems.System, PowerSystems.PowerLoad, or PowerSystems.ACBus
  • horizon::Int: shorter time window than the full results
  • initial_time::Dates.DateTime: start time other than the results initial time
  • linestyle::Symbol = :solid: line style
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • extra_load: optional per-timestep values added to demand (e.g. storage charging)
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_demand.

source
PowerGraphics.plot_demandMethod
plot_demand(
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
)

Plot demand from simulation results or a system load forecast.

Arguments

Keyword Arguments

  • aggregate: "System", "PowerLoad", or "Bus" — aggregate demand by PowerSystems.System, PowerSystems.PowerLoad, or PowerSystems.ACBus
  • horizon::Int: shorter time window than the full results
  • initial_time::Dates.DateTime: start time other than the results initial time
  • linestyle::Symbol = :solid: line style
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • extra_load: optional per-timestep values added to demand (e.g. storage charging)
  • Plot styling keywords: shared options (stack, bar, title, …)

Example

res = PowerSimulations.solve_op_problem!(OpProblem)
plot = plot_demand(res)

See also plot_demand!, plot_fuel, plot_dataframe.

source
PowerGraphics.plot_demand_plotly!Method
plot_demand_plotly!(
    p,
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
)
plot_demand!(
    p,
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
) -> Any

Plot demand onto an existing plot handle.

Arguments

Keyword Arguments

  • aggregate: "System", "PowerLoad", or "Bus" — aggregate demand by PowerSystems.System, PowerSystems.PowerLoad, or PowerSystems.ACBus
  • horizon::Int: shorter time window than the full results
  • initial_time::Dates.DateTime: start time other than the results initial time
  • linestyle::Symbol = :solid: line style
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • extra_load: optional per-timestep values added to demand (e.g. storage charging)
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_demand.

source
PowerGraphics.plot_demand_plotlyMethod
plot_demand_plotly(
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
)
plot_demand(
    result::Union{InfrastructureSystems.Results, PowerSystems.System};
    kwargs...
)

Plot demand from simulation results or a system load forecast.

Arguments

Keyword Arguments

  • aggregate: "System", "PowerLoad", or "Bus" — aggregate demand by PowerSystems.System, PowerSystems.PowerLoad, or PowerSystems.ACBus
  • horizon::Int: shorter time window than the full results
  • initial_time::Dates.DateTime: start time other than the results initial time
  • linestyle::Symbol = :solid: line style
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • extra_load: optional per-timestep values added to demand (e.g. storage charging)
  • Plot styling keywords: shared options (stack, bar, title, …)

Example

res = PowerSimulations.solve_op_problem!(OpProblem)
plot = plot_demand(res)

See also plot_demand!, plot_fuel, plot_dataframe.

source
PowerGraphics.plot_fuel!Method
plot_fuel!(
    p,
    result::InfrastructureSystems.Results;
    kwargs...
) -> Any

Plot stacked generation by fuel type onto an existing plot handle.

Defaults to stack = true.

Arguments

Keyword Arguments

  • generator_mapping_file: path to YAML defining generator category by fuel and prime mover
  • variables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plot
  • slacks::Bool = true: display slack variables
  • load::Bool = true: overlay demand (net load) line
  • curtailment::Bool = true: include curtailment in the stack
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • auto_units::Bool = true: auto-select MW/GW/TW from peak stacked total
  • power_scale: explicit divisor applied to plotted values (disables auto units)
  • y_label: explicit y-axis label
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_fuel.

source
PowerGraphics.plot_fuelMethod
plot_fuel(result::InfrastructureSystems.Results; kwargs...)

Plot stacked generation by fuel type with category-specific colors.

Uses PowerAnalytics.get_generation_data, PowerAnalytics.make_fuel_dictionary, and PowerAnalytics.categorize_data. Defaults to stack = true.

Arguments

Keyword Arguments

  • generator_mapping_file: path to YAML defining generator category by fuel and prime mover
  • variables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plot
  • slacks::Bool = true: display slack variables
  • load::Bool = true: overlay demand (net load) line
  • curtailment::Bool = true: include curtailment in the stack
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • auto_units::Bool = true: auto-select MW/GW/TW from peak stacked total
  • power_scale: explicit divisor applied to plotted values (disables auto units)
  • y_label: explicit y-axis label
  • Plot styling keywords: shared options (stack, bar, title, …)

Example

res = solve_op_problem!(OpProblem)
plot = plot_fuel(res)

See also plot_fuel!, plot_demand, plot_powerdata.

source
PowerGraphics.plot_fuel_plotly!Method
plot_fuel_plotly!(
    p,
    result::InfrastructureSystems.Results;
    kwargs...
)
plot_fuel!(
    p,
    result::InfrastructureSystems.Results;
    kwargs...
) -> Any

Plot stacked generation by fuel type onto an existing plot handle.

Defaults to stack = true.

Arguments

Keyword Arguments

  • generator_mapping_file: path to YAML defining generator category by fuel and prime mover
  • variables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plot
  • slacks::Bool = true: display slack variables
  • load::Bool = true: overlay demand (net load) line
  • curtailment::Bool = true: include curtailment in the stack
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • auto_units::Bool = true: auto-select MW/GW/TW from peak stacked total
  • power_scale: explicit divisor applied to plotted values (disables auto units)
  • y_label: explicit y-axis label
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_fuel.

source
PowerGraphics.plot_fuel_plotlyMethod
plot_fuel_plotly(
    result::InfrastructureSystems.Results;
    kwargs...
)
plot_fuel(result::InfrastructureSystems.Results; kwargs...)

Plot stacked generation by fuel type with category-specific colors.

Uses PowerAnalytics.get_generation_data, PowerAnalytics.make_fuel_dictionary, and PowerAnalytics.categorize_data. Defaults to stack = true.

Arguments

Keyword Arguments

  • generator_mapping_file: path to YAML defining generator category by fuel and prime mover
  • variables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plot
  • slacks::Bool = true: display slack variables
  • load::Bool = true: overlay demand (net load) line
  • curtailment::Bool = true: include curtailment in the stack
  • filter_func::Function: filter components included in the plot (default: available components)
  • palette: color palette from load_palette
  • auto_units::Bool = true: auto-select MW/GW/TW from peak stacked total
  • power_scale: explicit divisor applied to plotted values (disables auto units)
  • y_label: explicit y-axis label
  • Plot styling keywords: shared options (stack, bar, title, …)

Example

res = solve_op_problem!(OpProblem)
plot = plot_fuel(res)

See also plot_fuel!, plot_demand, plot_powerdata.

source
PowerGraphics.plot_powerdata!Method
plot_powerdata!(
    p,
    powerdata::PowerAnalytics.PowerData;
    kwargs...
) -> Any

Plot a PowerAnalytics.PowerData onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_powerdata)
  • powerdata: PowerAnalytics.PowerData to plot

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories); when false, plot each column and apply label_fn to raw Variable__Component names
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_powerdata.

source
PowerGraphics.plot_powerdataMethod
plot_powerdata(
    powerdata::PowerAnalytics.PowerData;
    kwargs...
)

Plot a PowerAnalytics.PowerData object (e.g. from PowerAnalytics.get_generation_data).

Arguments

  • powerdata: PowerAnalytics.PowerData to plot

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories); when false, plot each column and apply label_fn to raw Variable__Component names
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_powerdata!, plot_results, plot_fuel.

source
PowerGraphics.plot_powerdata_plotly!Method
plot_powerdata_plotly!(
    p,
    powerdata::PowerAnalytics.PowerData;
    kwargs...
)
plot_powerdata!(
    p,
    powerdata::PowerAnalytics.PowerData;
    kwargs...
) -> Any

Plot a PowerAnalytics.PowerData onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_powerdata)
  • powerdata: PowerAnalytics.PowerData to plot

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories); when false, plot each column and apply label_fn to raw Variable__Component names
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_powerdata.

source
PowerGraphics.plot_powerdata_plotlyMethod
plot_powerdata_plotly(
    powerdata::PowerAnalytics.PowerData;
    kwargs...
)
plot_powerdata(
    powerdata::PowerAnalytics.PowerData;
    kwargs...
)

Plot a PowerAnalytics.PowerData object (e.g. from PowerAnalytics.get_generation_data).

Arguments

  • powerdata: PowerAnalytics.PowerData to plot

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories); when false, plot each column and apply label_fn to raw Variable__Component names
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_powerdata!, plot_results, plot_fuel.

source
PowerGraphics.plot_results!Method
plot_results!(
    p,
    results::Dict{String, DataFrames.DataFrame};
    kwargs...
) -> Any

Plot a results dictionary onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_results)
  • results: Dict{String, DataFrame} of series tables

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories)
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_results.

source
PowerGraphics.plot_resultsMethod
plot_results(
    results::Dict{String, DataFrames.DataFrame};
    kwargs...
)

Plot a results dictionary of named DataFrames.DataFrames by wrapping them as PowerAnalytics.PowerData.

Arguments

  • results: Dict{String, DataFrame} of series tables

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories)
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_results!, plot_powerdata.

source
PowerGraphics.plot_results_plotly!Method
plot_results_plotly!(
    p,
    results::Dict{String, DataFrame};
    kwargs...
)
plot_results!(
    p,
    results::Dict{String, DataFrames.DataFrame};
    kwargs...
) -> Any

Plot a results dictionary onto an existing plot handle.

Arguments

  • p: existing plot handle from a previous PowerGraphics plot call (e.g. plot_results)
  • results: Dict{String, DataFrame} of series tables

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories)
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_results.

source
PowerGraphics.plot_results_plotlyMethod
plot_results_plotly(
    results::Dict{String, DataFrame};
    kwargs...
)
plot_results(
    results::Dict{String, DataFrames.DataFrame};
    kwargs...
)

Plot a results dictionary of named DataFrames.DataFrames by wrapping them as PowerAnalytics.PowerData.

Arguments

  • results: Dict{String, DataFrame} of series tables

Keyword Arguments

  • combine_categories::Bool = true: aggregate category columns before plotting (via PowerAnalytics.combine_categories)
  • curtailment::Bool: include curtailment with the variable data when present
  • Plot styling keywords: shared options (stack, bar, title, …)

See also plot_results!, plot_powerdata.

source
PowerGraphics.reportFunction

Generate a Weave report (PDF or HTML) from simulation results.

Uses Weave.jl with a Julia markdown (.jmd) template. An example template is available here.

Requires using Weave so the WeaveExt package extension is loaded.

Arguments

  • res: an InfrastructureSystems.Results object
  • out_path::String: directory for the generated report
  • design_template::String: path to the .jmd report design

Keyword Arguments

  • doctype::String = "md2pdf": Weave output type ("md2pdf" or "md2html")
  • backend::PlottingBackend = CairoMakieBackend(): plotting backend for figures in the report

Example

report(res, out_path, design_template)
source
PowerGraphics.save_plotFunction

Save a plot to filename.

The backend is inferred from the plot object: CairoMakie writes png/pdf/svg; PlotlyLight writes html.

Arguments

  • plot: plot object returned by a plot_* function
  • filename::String: output path

Keyword Arguments

  • PlotlyLight only: default_width, default_height
  • CairoMakie has no save-time size kwargs; figure size is fixed when the plot is created.

Example

plot = plot_fuel(res)
save_plot(plot, "my_plot.png")
source