
Plot trade as a network: capacities and flows between regions
Source:R/plot_trade_network.R
plot_trade_network.RdDraws trade objects as a network of regions (nodes) and links, one link per
pair of regions and commodity, its width set by a value: the input
capacities of the trade objects, the solved trade capacity (vTradeCap), or
the solved flows (vTradeIr). Links are quadratic curves whose bends are
flipped to reduce crossings.
Nodes are placed at region centroids when a map (an sf object or a
geoscales::GeoScale) is given or the model carries a geoscale; otherwise
they are laid out on a circle and no geography is needed.
Usage
plot_trade_network(
object,
map = NULL,
value = c("input", "capacity", "flow"),
year = NULL,
timeslice = "ANNUAL",
level = NULL,
curvature = 0.15,
labels = TRUE,
node_size = TRUE,
...
)Arguments
- object
a
trade, a list of trades, or arepository,modelorscenario(all of whose trade objects are drawn).value = "capacity"and"flow"need a solvedscenario.- map
optional
sfobject withregion(andx,y) columns, or ageoscales::GeoScale. WhenNULL, the object's geoscale is used if it has one, else a circular layout.- value
what sets the link width:
"input": the trade objects'@capacityinyear– existing links (stock> 0) solid, width = stock, with a faint band up tocap.up; projects (no stock, expandable throughncap.up,cap.upor an@invcostrow) dashed, width =cap.up(elsencap.up);"capacity": the solvedvTradeCapinyear;"flow": the solvedvTradeIrinyear, netted per pair; the arrow points in the net direction.
- year
the year to draw; default the first year present.
- timeslice
for
value = "flow":"ANNUAL"(default), the year's total asgetData(timeframe = "lowest")returns it (weighted to the full year on a sampled calendar); or any timeslice of the calendar – a day, an hour – for that snapshot.- level
for a geoscale
map: the level to draw; routes are lifted to it and those inside one region dropped.- curvature
bend of the links as a share of their length (0 = straight).
- labels
draw region names.
- node_size
scale nodes by the total value of their links.
- ...
unused.