message_ix_models.model.transport.plot.ComparePDTCap1
- class message_ix_models.model.transport.plot.ComparePDTCap1[source]
Bases:
Plot
Passenger 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])Use a custom output path.
generate
(*paths)Generate and return the plot.
ggtitle
([extra])Return
plotnine.ggtitle
including the current date & time.groupby_plot
(data, *args)Combination of groupby and ggplot().
make_task
(*inputs)Return a task
tuple
to add to a Computer.save
(config, *args, **kwargs)Prepare data, call
generate()
, and save to file.Attributes
File name base for saving the plot.
Keys
referring toQuantities
or other inputs accepted bygenerate()
.Path for file output.
False
for plots not intended to be run on a solved scenario.Keyword arguments for
plotnine.ggplot.save
.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
Use a custom output path.
- 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 (
Sequence
ofpandas.DataFrame
orother
) –One argument is given corresponding to each of the
inputs
.Because
plotnine
operates on pandas data structures,save()
automatically converts anyQuantity
inputs topandas.DataFrame
before they are passed togenerate()
.
- groupby_plot(data: DataFrame, *args)
Combination of groupby and ggplot().
Groups by args and yields a series of
plotnine.ggplot
objects, one per group, withstatic
geoms andggtitle()
appended to each.
- inputs: Sequence[Hashable] = []
Keys
referring toQuantities
or other inputs accepted bygenerate()
.
- classmethod make_task(*inputs)
Return a task
tuple
to add to a Computer.Deprecated since version 1.18.0: Use
add_tasks()
instead.- Parameters:
*inputs (.Key or
str
orhashable
, optional) – If provided, overrides theinputs
property 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
Prepare data, call
generate()
, and save to file.This method is used as the callable in the task generated by
add_tasks()
.New in version 1.24.1: This method uses
disable_copy_on_write()
to work around has2k1/mizani#38. This may cause issues if other computations (for instance, of the inputs to the Plot) rely on Pandas’ copy-on-write behaviour being enabled.
- static: List['plotnine.typing.PlotAddable'] = [<plotnine.themes.theme.theme object>, {'x': 'gdp', 'y': 'value', 'color': 't'}, <plotnine.geoms.geom_line.geom_line object>, <plotnine.geoms.geom_point.geom_point object>, <plotnine.scales.scale_xy.scale_x_log10 object>, <plotnine.scales.scale_xy.scale_y_log10 object>, 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), <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.