From e81b2809e5cbb42266dc41db2f5329c1733fc733 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 13 Jan 2017 22:44:53 -0800 Subject: [PATCH] Cast stackplot input to float when required. --- lib/matplotlib/stackplot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/stackplot.py b/lib/matplotlib/stackplot.py index 79153966be27..accbfa97cc81 100644 --- a/lib/matplotlib/stackplot.py +++ b/lib/matplotlib/stackplot.py @@ -68,7 +68,8 @@ def stackplot(axes, x, *args, **kwargs): baseline = kwargs.pop('baseline', 'zero') # Assume data passed has not been 'stacked', so stack it here. - stack = np.cumsum(y, axis=0) + # We'll need a float buffer for the upcoming calculations. + stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32)) if baseline == 'zero': first_line = 0. @@ -79,7 +80,7 @@ def stackplot(axes, x, *args, **kwargs): elif baseline == 'wiggle': m = y.shape[0] - first_line = (y * (m - 0.5 - np.arange(0, m)[:, None])).sum(0) + first_line = (y * (m - 0.5 - np.arange(m)[:, None])).sum(0) first_line /= -m stack += first_line 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