Skip to contents

Plots of solved scenarios, of the objects that go into a model, maps and heat maps: every one a ggplot to extend

PDF, A4, 2 pages · energyRt 0.91.5.9015 (dev) · 2026-11-29
autoplot(scen)
Annual electricity generation mix by province and milestone year

The generation mix of comm = "ELC", by year, faceted by region. Storage charging plots below zero.

Capacity, by vintage
Installed capacity by province and year, coloured by vintage
autoplot(CO2CAP, "capacity", fill = "vintage", by = "vintage")

by = keeps vintage or cluster apart; fill = colours by any column of the mix.

A day of dispatch
Hourly dispatch in R05 on a July day of 2050, demand as a line
autoplot(CO2CAP, "generation", region = "R05", year = 2050, timeslice = "^d196_")

A timeslice pattern that selects one day switches to an hourly profile; demand is the line.

autoplot() on a scenario
autoplot.scenario(object, type, comm, region, year, timeslice, by, fill, facet, top_n, drop_small)
Draws the mix getMix() returns, with the same filters.
"generation" output of comm by process (default)
"capacity" installed capacity
"new_capacity" capacity built in each period
"fuel" inputs burnt to make comm
"storage" charge and discharge
facet = "region" the default when there are several
top_n = 6 the largest six; the rest is other
drop_small = 0.01 hide shares under 1%
Make it yours
autoplot(CO2CAP, "capacity") +
  labs(title = "Installed, GW") +
  theme_energyRt(base_size = 9)
Every plot is a ggplot: add layers, scales, labels, themes.
p <- autoplot(CO2CAP)
ggsave("mix.png", p, width = 7,
       height = 4, dpi = 300)
theme_energyRt(base_size, …)
The package theme, for plots of your own.
More scenario plots
Maps
Wind generation by province in 2030, 2040 and 2050
gg_map(CO2CAP, type = "generation", process = "EWIN", facet = "year")
gg_map(object, type, level, comm, year, process, geoscale, facet, …)
A mix by region on the geoscale's map; level = "zone" aggregates.

Maps need a geoscale with geometry: the model's own, or one given with geoscale = / map =.

Last of the gallery: autoplot(compare_scenarios(list(BASE, CO2CAP))), the objective of each scenario.

Flows between regions
Annual electricity flows between the three provinces in 2050
gg_trade_network(CO2CAP, value = "flow", year = 2050)
gg_trade_network(object, value, comm, year, timeslice, level, …)
value = "capacity", "flow" or "input"; arrows scale with it.
gg_trade_map(object, map, level, comm, …)
The routes declared, before or after solving.
Objects, before solving
Investment and operating windows of each process in the model

Parameters over the years, given points and interpolated lines (ECOA); a constraint's right-hand side (CO2_CAP); each process's investment and operating window (autoplot(mod)).

What each class draws
technology, storage, supply, import, export its parameters over the years; style = "profile", "bar", "regions", "map"; param = picks the slots
demand, weather, commodity the series they carry
constraint, tax, subsidy the bound or rate over the years
calendar, horizon the time structure (Time resolution)
model, repository type = "windows" or "objects"
levcost, comparisons, ensembles their results (Levelized cost, Results)

The diagram of a single process is draw() -- see Technology.

Heat maps
Electricity demand of R05 in 2050 by hour of the day and sampled day
dem <- getData(CO2CAP, name = "pDemand",
  region = "R05", year = 2050, merge = TRUE)
gg_heatmap(dem, calendar = cal, name = "GWh")
The finest level on the y axis, the next on x: here hours by the four sampled days.
gg_heatmap(object, calendar, value, facet, name, …)
Any table with a timeslice column: load, profiles, prices, output.
Other plots
gg_year_calendars(object, fill, …)
The calendar of each milestone year, where they differ.
gg_share_frontier(object, …)
The feasible input or output shares of a group (Levelized cost).
plot_geoscale(object, type, geoframe, …)
A region hierarchy (Spatial resolution).

plot_map(), plot_heatmap(), plot_trade_map(), plot_trade_network(), plot_share_frontier() are the old names of the gg_*() functions; they still work and say so.

Two scenarios side by side
CO2 emissions by year and province, without and with the cap
getData(list(BASE, CO2CAP),
  name = "vEmsFuelTot", merge = TRUE) |>
  ggplot(aes(factor(year), value,
             fill = region)) +
  geom_col() + facet_wrap(~scenario) +
  labs(x = NULL, y = "CO2") +
  theme_energyRt()
A list of scenarios gives a scenario column to facet on.
Pitfalls
  • autoplot() returns the plot; at the console it prints, in a script assign it or print() it.
  • A scenario plot shows the active run; read another with getData(run = ) and plot that.
  • Values are in the model's units, labelled value: name them with labs().
  • A per-slice plot is one occurrence of the slice; annual bars are already weighted.
More objects

EWIN, STG_ELC, WWIN, SUP_BIO and ECOA are TOPIA objects: getObject(kit$repo, name = "EWIN", drop = TRUE).