Skip to content

Commit

Permalink
Merge ca4ddac into 109251f
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Jan 10, 2017
2 parents 109251f + ca4ddac commit e282571
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Expand Up @@ -4023,7 +4023,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
edgecolors = 'face'
linewidths = rcParams['lines.linewidth']

offsets = np.dstack((x, y))
offsets = np.column_stack([x, y])

collection = mcoll.PathCollection(
(path,), scales,
Expand Down
20 changes: 6 additions & 14 deletions lib/matplotlib/collections.py
Expand Up @@ -145,7 +145,7 @@ def __init__(self,
self._uniform_offsets = None
self._offsets = np.array([[0, 0]], float)
if offsets is not None:
offsets = np.asanyarray(offsets).reshape((-1, 2))
offsets = np.asanyarray(offsets, float)
if transOffset is not None:
self._offsets = offsets
self._transOffset = transOffset
Expand Down Expand Up @@ -210,7 +210,6 @@ def get_datalim(self, transData):
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()

offsets = np.asanyarray(offsets, float).reshape((-1, 2))
if isinstance(offsets, np.ma.MaskedArray):
offsets = offsets.filled(np.nan)
# get_path_collection_extents handles nan but not masked arrays
Expand Down Expand Up @@ -244,14 +243,12 @@ def _prepare_points(self):
xs, ys = vertices[:, 0], vertices[:, 1]
xs = self.convert_xunits(xs)
ys = self.convert_yunits(ys)
paths.append(mpath.Path(list(zip(xs, ys)), path.codes))
paths.append(mpath.Path(np.column_stack([xs, ys]), path.codes))

if offsets.size > 0:
xs = self.convert_xunits(offsets[:, 0])
ys = self.convert_yunits(offsets[:, 1])
offsets = list(zip(xs, ys))

offsets = np.asanyarray(offsets, float).reshape((-1, 2))
offsets = np.column_stack([xs, ys])

if not transform.is_affine:
paths = [transform.transform_path_non_affine(path)
Expand Down Expand Up @@ -431,7 +428,7 @@ def set_offsets(self, offsets):
ACCEPTS: float or sequence of floats
"""
offsets = np.asanyarray(offsets, float).reshape((-1, 2))
offsets = np.asanyarray(offsets, float)
#This decision is based on how they are initialized above
if self._uniform_offsets is None:
self._offsets = offsets
Expand Down Expand Up @@ -1881,17 +1878,12 @@ def draw(self, renderer):
if len(self._offsets):
xs = self.convert_xunits(self._offsets[:, 0])
ys = self.convert_yunits(self._offsets[:, 1])
offsets = list(zip(xs, ys))

offsets = np.asarray(offsets, float).reshape((-1, 2))
offsets = np.column_stack([xs, ys])

self.update_scalarmappable()

if not transform.is_affine:
coordinates = self._coordinates.reshape(
(self._coordinates.shape[0] *
self._coordinates.shape[1],
2))
coordinates = self._coordinates.reshape((-1, 2))
coordinates = transform.transform(coordinates)
coordinates = coordinates.reshape(self._coordinates.shape)
transform = transforms.IdentityTransform()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_collections.py
Expand Up @@ -538,7 +538,7 @@ def test_regularpolycollection_rotate():
for xy, alpha in zip(xy_points, rotations):
col = mcollections.RegularPolyCollection(
4, sizes=(100,), rotation=alpha,
offsets=xy, transOffset=ax.transData)
offsets=[xy], transOffset=ax.transData)
ax.add_collection(col, autolim=True)
ax.autoscale_view()

Expand Down

0 comments on commit e282571

Please sign in to comment.