plt.stackplot not working for integer input with non-default 'baseline' parameters #7802

ulfaslak opened this Issue Jan 11, 2017 · 4 comments


None yet

4 participants


To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.

Bug report

plt.stackplot with non-default 'baseline' keyword option not working for integer input.

I wanted to use plt.stackplot with the baseline='sym' option, and noticed that it a TypeError with my data. Turned out it was just a matter of changin the input valued to float types, but it should work for integer arrays too.

Code for reproduction

def fnx():
    return np.random.randint(5, 50, 10)

x = np.arange(10)
y1, y2, y3 = fnx(), fnx(), fnx()

fig, ax = plt.subplots()
ax.stackplot(x, y1, y2, y3, baseline="sym")

Actual outcome

TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

Expected outcome

This nice figure:

screen shot 2017-01-11 at 18 35 19

Matplotlib version

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
>>> matplotlib.__version__

Python version 2.7.12
Platform OSX Version 10.12

  • How did you install Matplotlib and Python (pip, anaconda, from source ...)

wait, pylab has it's own version?!

QuLogic commented Jan 14, 2017 edited

That looks more like a NumPy version to me; probably it imports it with the *-import.


Oh, that makes sense. I miss-read it is '1.1.3' which might have actually been an mpl version.

NelleV commented Jan 15, 2017

closed by #7827

@NelleV NelleV closed this Jan 15, 2017
@QuLogic QuLogic added this to the 2.0.1 (next bug fix release) milestone Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment