fine for line_plot, but not for stack_plot


min@...
 

Hi all,

I see almost no one in this forum, so I am not sure whether this is for filing issues or not. But I give it a try. (If not here, should it be on GitHub?)

I am trying to plot a stacked plot and getting an error, while I find it working fine with a line plot. I expect they should work in the same setting, but they aren't. Why?

Thanks!

Jihoon

data.filter(region="World").stack_plot()
Traceback (most recent call last):
  File "<ipython-input-19-6aa8ca15d58f>", line 1, in <module>
    data.filter(region="World").stack_plot()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyam\core.py", line 1227, in stack_plot
    ax = plotting.stack_plot(df, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyam\plotting.py", line 503, in stack_plot
    upper = positive_only_cumulative.iloc[:, 0].values
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1418, in __getitem__
    return self._getitem_tuple(key)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2092, in _getitem_tuple
    self._has_valid_tuple(tup)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 235, in _has_valid_tuple
    self._validate_key(k, i)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2014, in _validate_key
    self._validate_integer(key, axis)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2088, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds


Daniel Huppmann
 

Hi Jihoon,

Indeed, the mailing list is still quite new, there hasn’t been much discussion yet - so it’s great that you start using it. I hope that your issue will encourage others to post their questions and ideas here!

Regarding whether to use GitHub issues or this mailing list - whatever a user feels more comfortable with! It should be the responsibility of developers and more experienced users responding to questions to make any relevant cross-references (as I do below).

About the issue: I think that is related to the latest version of matplotlib - see issue #281 where Jarmo reports a similar problem for scatter(). Can you check which version of matplotlib you have installed, and if it is more recent, downgrade to 3.0.2? It this solves your problem, please add a comment to the issue that it also affects stack-plots.

If that’s not the underlying issue for your problem: please start a new issue, where we can discuss other causes (for such discussions, I think that GitHub issues are better suited than the mailing list).

Best,
Daniel


Am 19.11.2019 um 12:59 schrieb min@...:

Hi all,

I see almost no one in this forum, so I am not sure whether this is for filing issues or not. But I give it a try. (If not here, should it be on GitHub?)

I am trying to plot a stacked plot and getting an error, while I find it working fine with a line plot. I expect they should work in the same setting, but they aren't. Why?

Thanks!

Jihoon
data.filter(region="World").stack_plot()
Traceback (most recent call last):
  File "<ipython-input-19-6aa8ca15d58f>", line 1, in <module>
    data.filter(region="World").stack_plot()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyam\core.py", line 1227, in stack_plot
    ax = plotting.stack_plot(df, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyam\plotting.py", line 503, in stack_plot
    upper = positive_only_cumulative.iloc[:, 0].values
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1418, in __getitem__
    return self._getitem_tuple(key)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2092, in _getitem_tuple
    self._has_valid_tuple(tup)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 235, in _has_valid_tuple
    self._validate_key(k, i)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2014, in _validate_key
    self._validate_integer(key, axis)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2088, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds