Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
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