Skip to content

Commit 86bf661

Browse files
authored
Merge pull request #7827 from anntzer/stackplot-integer-input
MNT: Cast stackplot input to float when required.
2 parents 70bb531 + e81b280 commit 86bf661

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/stackplot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def stackplot(axes, x, *args, **kwargs):
6868

6969
baseline = kwargs.pop('baseline', 'zero')
7070
# Assume data passed has not been 'stacked', so stack it here.
71-
stack = np.cumsum(y, axis=0)
71+
# We'll need a float buffer for the upcoming calculations.
72+
stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32))
7273

7374
if baseline == 'zero':
7475
first_line = 0.
@@ -79,7 +80,7 @@ def stackplot(axes, x, *args, **kwargs):
7980

8081
elif baseline == 'wiggle':
8182
m = y.shape[0]
82-
first_line = (y * (m - 0.5 - np.arange(0, m)[:, None])).sum(0)
83+
first_line = (y * (m - 0.5 - np.arange(m)[:, None])).sum(0)
8384
first_line /= -m
8485
stack += first_line
8586

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy