|
11 | 11 | """ |
12 | 12 |
|
13 | 13 | from collections import defaultdict |
14 | | -import functools |
15 | 14 | import itertools |
16 | 15 | import math |
17 | 16 | import textwrap |
@@ -1909,8 +1908,7 @@ def plot(self, xs, ys, *args, zdir='z', **kwargs): |
1909 | 1908 | else: |
1910 | 1909 | zs = kwargs.pop('zs', 0) |
1911 | 1910 |
|
1912 | | - # Match length |
1913 | | - zs = np.broadcast_to(zs, np.shape(xs)) |
| 1911 | + xs, ys, zs = cbook._broadcast_with_masks(xs, ys, zs) |
1914 | 1912 |
|
1915 | 1913 | lines = super().plot(xs, ys, *args, **kwargs) |
1916 | 1914 | for line in lines: |
@@ -2665,8 +2663,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True, |
2665 | 2663 | had_data = self.has_data() |
2666 | 2664 | zs_orig = zs |
2667 | 2665 |
|
2668 | | - xs, ys, zs = np.broadcast_arrays( |
2669 | | - *[np.ravel(np.ma.filled(t, np.nan)) for t in [xs, ys, zs]]) |
| 2666 | + xs, ys, zs = cbook._broadcast_with_masks(xs, ys, zs) |
2670 | 2667 | s = np.ma.ravel(s) # This doesn't have to match x, y in size. |
2671 | 2668 |
|
2672 | 2669 | xs, ys, zs, s, c, color = cbook.delete_masked_points( |
@@ -2722,7 +2719,7 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs): |
2722 | 2719 |
|
2723 | 2720 | patches = super().bar(left, height, *args, **kwargs) |
2724 | 2721 |
|
2725 | | - zs = np.broadcast_to(zs, len(left)) |
| 2722 | + zs = np.broadcast_to(zs, len(left), subok=True) |
2726 | 2723 |
|
2727 | 2724 | verts = [] |
2728 | 2725 | verts_zs = [] |
@@ -2988,23 +2985,8 @@ def calc_arrows(UVW): |
2988 | 2985 |
|
2989 | 2986 | had_data = self.has_data() |
2990 | 2987 |
|
2991 | | - input_args = [X, Y, Z, U, V, W] |
2992 | | - |
2993 | | - # extract the masks, if any |
2994 | | - masks = [k.mask for k in input_args |
2995 | | - if isinstance(k, np.ma.MaskedArray)] |
2996 | | - # broadcast to match the shape |
2997 | | - bcast = np.broadcast_arrays(*input_args, *masks) |
2998 | | - input_args = bcast[:6] |
2999 | | - masks = bcast[6:] |
3000 | | - if masks: |
3001 | | - # combine the masks into one |
3002 | | - mask = functools.reduce(np.logical_or, masks) |
3003 | | - # put mask on and compress |
3004 | | - input_args = [np.ma.array(k, mask=mask).compressed() |
3005 | | - for k in input_args] |
3006 | | - else: |
3007 | | - input_args = [np.ravel(k) for k in input_args] |
| 2988 | + input_args = cbook._broadcast_with_masks(X, Y, Z, U, V, W, |
| 2989 | + compress=True) |
3008 | 2990 |
|
3009 | 2991 | if any(len(v) == 0 for v in input_args): |
3010 | 2992 | # No quivers, so just make an empty collection and return early |
|
0 commit comments