Skip to content

Commit

Permalink
Add docstrings to plotting functions pyam.plot.<kind>() (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Jan 25, 2021
1 parent 6034aa5 commit c1346b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [#481](https://github.com/IAMconsortium/pyam/pull/481) Enable custom index columns
- [#477](https://github.com/IAMconsortium/pyam/pull/477) Add a nightly test suite
- [#476](https://github.com/IAMconsortium/pyam/pull/476) Add docstrings to plotting functions `df.plot.<kind>()`
- [#471](https://github.com/IAMconsortium/pyam/pull/471) Add a `iiasa.Connection.properties()` function to retrieve scenario audit data

# Release v0.10.0
Expand Down
18 changes: 16 additions & 2 deletions pyam/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pyam.logging import deprecation_warning
from pyam.run_control import run_control
from pyam import figures
from pyam.figures import sankey
from pyam.timeseries import cross_threshold
from pyam.utils import META_IDX, IAMC_IDX, SORT_IDX, YEAR_IDX,\
isstr, islistable, _raise_data_error
Expand Down Expand Up @@ -77,6 +77,20 @@ class PlotAccessor():
def __init__(self, df):
self._parent = df

# assign plotting functions as attributes
PLOT_MAPPING = {
'line': line,
'bar': bar,
'stack': stack,
'box': box,
'pie': pie,
'scatter': scatter,
'sankey': sankey
}
# inherit the docstring from the plot function
for name, func in PLOT_MAPPING.items():
getattr(self, name).__func__.__doc__ = func.__doc__

def __call__(self, kind='line', *args, **kwargs):
return getattr(self, kind)(**kwargs)

Expand All @@ -102,7 +116,7 @@ def scatter(self, *args, **kwargs):
return scatter(self._parent, *args, **kwargs)

def sankey(self, *args, **kwargs):
return figures.sankey(self._parent, *args, **kwargs)
return sankey(self._parent, *args, **kwargs)


def reset_default_props(**kwargs):
Expand Down

0 comments on commit c1346b6

Please sign in to comment.