Skip to content

Commit 27ab206

Browse files
committed
Ignore transOffset if no offsets passed to Collection
This fixes a regression from #20717 in networkx (Fixes #21517), but we'll go forward with the change in a later release to give them time to fix it.
1 parent 460073b commit 27ab206

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst

+4
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ Miscellaneous deprecations
269269
- ``cm.LUTSIZE`` is deprecated. Use :rc:`image.lut` instead. This value only
270270
affects colormap quantization levels for default colormaps generated at
271271
module import time.
272+
- ``Collection.__init__`` previously ignored *transOffset* without *offsets* also
273+
being specified. In the future, *transOffset* will begin having an effect
274+
regardless of *offsets*. In the meantime, if you wish to set *transOffset*,
275+
call `.Collection.set_offset_transform` explicitly.
272276
- ``Colorbar.patch`` is deprecated; this attribute is not correctly updated
273277
anymore.
274278
- ``ContourLabeler.get_label_width`` is deprecated.

lib/matplotlib/collections.py

+12
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ def __init__(self,
202202
if offsets.shape == (2,):
203203
offsets = offsets[None, :]
204204
self._offsets = offsets
205+
elif transOffset is not None:
206+
_api.warn_deprecated(
207+
'3.5',
208+
removal='3.6',
209+
message='Passing *transOffset* without *offsets* has no '
210+
'effect. This behavior is deprecated since %(since)s '
211+
'and %(removal)s, *transOffset* will begin having an '
212+
'effect regardless of *offsets*. In the meantime, if '
213+
'you wish to set *transOffset*, call '
214+
'collection.set_offset_transform(transOffset) '
215+
'explicitly.')
216+
transOffset = None
205217

206218
self._transOffset = transOffset
207219

lib/matplotlib/tests/test_collections.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,13 @@ def test_set_offsets_late():
10721072

10731073

10741074
def test_set_offset_transform():
1075+
with pytest.warns(MatplotlibDeprecationWarning,
1076+
match='.transOffset. without .offsets. has no effect'):
1077+
mcollections.Collection([],
1078+
transOffset=mtransforms.IdentityTransform())
1079+
10751080
skew = mtransforms.Affine2D().skew(2, 2)
1076-
init = mcollections.Collection([], transOffset=skew)
1081+
init = mcollections.Collection([], offsets=[], transOffset=skew)
10771082

10781083
late = mcollections.Collection([])
10791084
late.set_offset_transform(skew)

0 commit comments

Comments
 (0)