Cast stackplot input to float when required. #7827

Merged
merged 1 commit into from Jan 15, 2017
Jump to file
+3 −2
Split
@@ -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