|
11 | 11 | """
|
12 | 12 | from __future__ import (absolute_import, division, print_function,
|
13 | 13 | unicode_literals)
|
14 |
| -import math |
15 | 14 |
|
16 | 15 | import six
|
17 | 16 | from six.moves import map, xrange, zip, reduce
|
18 | 17 |
|
| 18 | +import math |
19 | 19 | import warnings
|
20 | 20 |
|
21 | 21 | import numpy as np
|
22 |
| -import matplotlib.axes as maxes |
| 22 | + |
| 23 | +from matplotlib import ( |
| 24 | + axes as maxes, cbook, collections as mcoll, colors as mcolors, docstring, |
| 25 | + scale as mscale, transforms as mtransforms) |
| 26 | +from matplotlib._backports import numpy as _backports_np |
23 | 27 | from matplotlib.axes import Axes, rcParams
|
24 |
| -from matplotlib import cbook |
25 |
| -import matplotlib.transforms as mtransforms |
| 28 | +from matplotlib.colors import Normalize, LightSource |
26 | 29 | from matplotlib.transforms import Bbox
|
27 |
| -import matplotlib.collections as mcoll |
28 |
| -from matplotlib import docstring |
29 |
| -import matplotlib.scale as mscale |
30 | 30 | from matplotlib.tri.triangulation import Triangulation
|
31 |
| -from matplotlib import colors as mcolors |
32 |
| -from matplotlib.colors import Normalize, LightSource |
33 | 31 |
|
34 | 32 | from . import art3d
|
35 | 33 | from . import proj3d
|
@@ -1536,8 +1534,7 @@ def plot(self, xs, ys, *args, **kwargs):
|
1536 | 1534 | zdir = kwargs.pop('zdir', 'z')
|
1537 | 1535 |
|
1538 | 1536 | # Match length
|
1539 |
| - if not cbook.iterable(zs): |
1540 |
| - zs = np.ones(len(xs)) * zs |
| 1537 | + zs = _backports_np.broadcast_to(zs, len(xs)) |
1541 | 1538 |
|
1542 | 1539 | lines = super(Axes3D, self).plot(xs, ys, *args, **kwargs)
|
1543 | 1540 | for line in lines:
|
@@ -2332,18 +2329,16 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
|
2332 | 2329 |
|
2333 | 2330 | had_data = self.has_data()
|
2334 | 2331 |
|
2335 |
| - xs, ys, zs = np.broadcast_arrays(*map(np.ma.ravel, [xs, ys, zs])) |
| 2332 | + xs, ys, zs = np.broadcast_arrays( |
| 2333 | + *[np.ravel(np.ma.filled(t, np.nan)) for t in [xs, ys, zs]]) |
2336 | 2334 | s = np.ma.ravel(s) # This doesn't have to match x, y in size.
|
2337 | 2335 |
|
2338 | 2336 | xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
|
2339 | 2337 |
|
2340 |
| - patches = super(Axes3D, self).scatter(xs, ys, s=s, c=c, *args, |
2341 |
| - **kwargs) |
2342 |
| - if not cbook.iterable(zs): |
2343 |
| - is_2d = True |
2344 |
| - zs = np.ones(len(xs)) * zs |
2345 |
| - else: |
2346 |
| - is_2d = False |
| 2338 | + patches = super(Axes3D, self).scatter( |
| 2339 | + xs, ys, s=s, c=c, *args, **kwargs) |
| 2340 | + is_2d = not cbook.iterable(zs) |
| 2341 | + zs = _backports_np.broadcast_to(zs, len(xs)) |
2347 | 2342 | art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir,
|
2348 | 2343 | depthshade=depthshade)
|
2349 | 2344 |
|
@@ -2382,8 +2377,7 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
|
2382 | 2377 |
|
2383 | 2378 | patches = super(Axes3D, self).bar(left, height, *args, **kwargs)
|
2384 | 2379 |
|
2385 |
| - if not cbook.iterable(zs): |
2386 |
| - zs = np.ones(len(left)) * zs |
| 2380 | + zs = _backports_np.broadcast_to(zs, len(left)) |
2387 | 2381 |
|
2388 | 2382 | verts = []
|
2389 | 2383 | verts_zs = []
|
|
0 commit comments