message_ix_models.model.transport.plot.ComparePDTCap1
- class message_ix_models.model.transport.plot.ComparePDTCap1[source]
Bases:
PlotPassenger activity.
Similar to
DemandExoCap1, except comparing multiple scenarios.One page per \(n\).
5 horizontal panels for scenarios.
One line with points per \(t\) (=transport mode), coloured by mode.
- __init__()
Methods
__init__()add_tasks(c, key, *inputs[, strict])Add tasks to c to generate and save the Plot.
generate(*paths)Generate and return the plot.
ggtitle([extra])Return
plotnine.ggtitleincluding the current date & time.groupby_plot(data, *args)Combination of groupby and ggplot().
make_task(*inputs)Return a task
tupleto add to a Computer.save(config, *args, **kwargs)Store the last 2 args appended by
add_tasks().Attributes
File name base for saving the plot.
Keysreferring toQuantitiesor other inputs accepted bygenerate().Path for file output.
Keyword arguments for
plotnine.ggplot.save.Trueif the plot is to be used in aReporterwith keys/tasks for reporting a single scenario.Workflow stage at which the Plot is to be used.
list of plotnine objects that are not dynamic.
File extension; determines file format.
Fixed plot title string.
Units expression for plot title.
- classmethod add_tasks(c: Computer, key: KeyLike, *inputs, strict: bool = False) KeyLike
Add tasks to c to generate and save the Plot.
Beyond the base class method, this method:
Constructs an output path from
basename,suffix, and themake_output_path()operator. This in turn uses thec.configvalues “output_dir” (ifstageis.STAGE.REPORT) or “build debug dir”.If
single is False, adds a key “scenario” with a dummy URL that can be used byggtitle().Appends 2 keys for the above to the inputs for use by
save().
- basename = 'compare-pdt-capita-gdp'
File name base for saving the plot.
- generate(*paths: Path)[source]
Generate and return the plot.
A subclass of Plot must implement this method.
- Parameters:
args (
Sequenceofpandas.DataFrameorother) –One argument is given corresponding to each of the
inputs.Because
plotnineoperates on pandas data structures,save()automatically converts anyQuantityinputs topandas.DataFramebefore they are passed togenerate().
- ggtitle(extra: str | None = None) PlotAddable
Return
plotnine.ggtitleincluding the current date & time.
- groupby_plot(data: DataFrame, *args)
Combination of groupby and ggplot().
Groups by args and yields a series of
plotnine.ggplotobjects, one per group, withstaticgeoms andggtitle()appended to each.
- inputs: Sequence['KeyLike'] = []
Keysreferring toQuantitiesor other inputs accepted bygenerate().
- classmethod make_task(*inputs)
Return a task
tupleto add to a Computer.Deprecated since version 1.18.0: Use
add_tasks()instead.- Parameters:
*inputs (.Key or
strorhashable, optional) – If provided, overrides theinputsproperty of the class.- Returns:
The first, callable element of the task is
save().The second element is
"config", to access the configuration of the Computer.The third and following elements are the inputs.
- Return type:
- path: Path | None = None
Path for file output. If it is not set,
save()will populate it with a value constructed fromconfig["output_dir"],basename, andsuffix. The implementation ofgenerate()in a Plot sub-class may assign any other value, for instance one constructed at runtime from theinputs.
- save(config, *args, **kwargs) Path | None
Store the last 2 args appended by
add_tasks().
- single: bool = False
Trueif the plot is to be used in aReporterwith keys/tasks for reporting a single scenario. UseFalsefor plots of data from multiple scenarios.
- stage: Literal[STAGE.BUILD, STAGE.REPORT] = 1
Workflow stage at which the Plot is to be used.
- static: list['PlotAddable'] = [<plotnine.themes.theme.theme object>, {'color': 't', 'x': 'gdp', 'y': 'value'}, <plotnine.geoms.geom_line.geom_line object>, <plotnine.geoms.geom_point.geom_point object>, scale_x_log10(name=None, breaks=True, limits=None, labels=True, expand=None, guide=None, na_value=nan, aesthetics=['x', 'xmin', 'xmax', 'xend', 'xintercept'], rescaler=<function rescale>, oob=<function censor>, minor_breaks=True, trans='log10'), scale_y_log10(name=None, breaks=True, limits=None, labels=True, expand=None, guide=None, na_value=nan, aesthetics=['y', 'ymin', 'ymax', 'yend', 'yintercept', 'ymin_final', 'ymax_final', 'lower', 'middle', 'upper'], rescaler=<function rescale>, oob=<function censor>, minor_breaks=True, trans='log10'), labs(x='GDP [10³ USD_2017 / capita]', y='', alpha=None, color='Transport mode', colour=None, fill=None, linetype=None, shape=None, size=None, stroke=None, title=None, subtitle=None, caption=None, tag=None), <plotnine.facets.facet_wrap.facet_wrap object>]
list of plotnine objects that are not dynamic.
- Type:
‘Static’ geoms
- suffix = '.pdf'
File extension; determines file format.