message_ix_models.model.transport.plot.MultiStock

class message_ix_models.model.transport.plot.MultiStock[source]

Bases: PlotFromIAMC

LDV technology stock.

__init__()

Methods

__init__()

add_tasks(c, key, *inputs[, strict])

Select a subset of data and reduce its dimensionality.

generate(data)

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)

Store the last 2 args appended by add_tasks().

Attributes

basename

File name base for saving the plot.

iamc_variable_pattern

variable argument to genno.compat.pyam.operator.quantity_from_iamc().

inputs

Keys referring to Quantities or other inputs accepted by generate().

path

Path for file output.

save_args

Keyword arguments for plotnine.ggplot.save.

single

True if the plot is to be used in a Reporter with keys/tasks for reporting a single scenario.

stage

Workflow stage at which the Plot is to be used.

static

list of plotnine objects that are not dynamic.

suffix

File extension; determines file format.

title

Fixed plot title string.

unit

Units expression for plot title.

classmethod add_tasks(c: Computer, key: KeyLike, *inputs, strict: bool = False) KeyLike

Select a subset of data and reduce its dimensionality.

basename = 'multi-stock'

File name base for saving the plot.

generate(data)[source]

Generate and return the plot.

A subclass of Plot must implement this method.

Parameters:

args (Sequence of pandas.DataFrame or other) –

One argument is given corresponding to each of the inputs.

Because plotnine operates on pandas data structures, save() automatically converts any Quantity inputs to pandas.DataFrame before they are passed to generate().

ggtitle(extra: str | None = None) PlotAddable

Return plotnine.ggtitle including the current date & time.

groupby_plot(data: DataFrame, *args)

Combination of groupby and ggplot().

Groups by args and yields a series of plotnine.ggplot objects, one per group, with static geoms and ggtitle() appended to each.

iamc_variable_pattern: str = 'Transport\\|Stock\\|Road\\|Passenger\\|LDV\\|(.*)'

variable argument to genno.compat.pyam.operator.quantity_from_iamc().

inputs: Sequence['KeyLike'] = ['all:n-s-UNIT-v-y']

Keys referring to Quantities or other inputs accepted by generate().

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 or hashable, optional) – If provided, overrides the inputs 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:

tuple

path: Path | None = None

Path for file output. If it is not set, save() will populate it with a value constructed from config["output_dir"], basename, and suffix. The implementation of generate() in a Plot sub-class may assign any other value, for instance one constructed at runtime from the inputs.

save(config, *args, **kwargs) Path | None

Store the last 2 args appended by add_tasks().

save_args: dict[str, Any] = {'verbose': False}

Keyword arguments for plotnine.ggplot.save.

single: bool = False

True if the plot is to be used in a Reporter with keys/tasks for reporting a single scenario. Use False for plots of data from multiple scenarios.

stage: Literal[STAGE.BUILD, STAGE.REPORT] = 3

Workflow stage at which the Plot is to be used.

static: list['PlotAddable'] = [<plotnine.themes.theme.theme object>, {'color': 'v', 'x': 'y', 'y': 'value'}, <plotnine.facets.facet_wrap.facet_wrap object>, <plotnine.geoms.geom_point.geom_point object>, <plotnine.geoms.geom_line.geom_line object>, scale_color_brewer(name=None, breaks=True, limits=None, labels=True, expand=None, guide='legend', na_value='#7F7F7F', aesthetics=['color'], drop=True, na_translate=True), labs(x='Period', y='', alpha=None, color='Technology', colour=None, fill=None, linetype=None, shape=None, size=None, stroke=None, title=None, subtitle=None, caption=None, tag=None), <plotnine.themes.theme.theme object>]

list of plotnine objects that are not dynamic.

Type:

‘Static’ geoms

suffix = '.pdf'

File extension; determines file format.

title: str | None = None

Fixed plot title string. If not given, the first line of the class docstring is used.

unit: str | None = None

Units expression for plot title.