Skip to content

Commit

Permalink
Ignore transOffset if no offsets passed to Collection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
QuLogic committed Nov 6, 2021
1 parent 460073b commit 27ab206
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst
Expand Up @@ -269,6 +269,10 @@ Miscellaneous deprecations
- ``cm.LUTSIZE`` is deprecated. Use :rc:`image.lut` instead. This value only
affects colormap quantization levels for default colormaps generated at
module import time.
- ``Collection.__init__`` previously ignored *transOffset* without *offsets* also
being specified. In the future, *transOffset* will begin having an effect
regardless of *offsets*. In the meantime, if you wish to set *transOffset*,
call `.Collection.set_offset_transform` explicitly.
- ``Colorbar.patch`` is deprecated; this attribute is not correctly updated
anymore.
- ``ContourLabeler.get_label_width`` is deprecated.
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/collections.py
Expand Up @@ -202,6 +202,18 @@ def __init__(self,
if offsets.shape == (2,):
offsets = offsets[None, :]
self._offsets = offsets
elif transOffset is not None:
_api.warn_deprecated(
'3.5',
removal='3.6',
message='Passing *transOffset* without *offsets* has no '
'effect. This behavior is deprecated since %(since)s '
'and %(removal)s, *transOffset* will begin having an '
'effect regardless of *offsets*. In the meantime, if '
'you wish to set *transOffset*, call '
'collection.set_offset_transform(transOffset) '
'explicitly.')
transOffset = None

self._transOffset = transOffset

Expand Down
7 changes: 6 additions & 1 deletion lib/matplotlib/tests/test_collections.py
Expand Up @@ -1072,8 +1072,13 @@ def test_set_offsets_late():


def test_set_offset_transform():
with pytest.warns(MatplotlibDeprecationWarning,
match='.transOffset. without .offsets. has no effect'):
mcollections.Collection([],
transOffset=mtransforms.IdentityTransform())

skew = mtransforms.Affine2D().skew(2, 2)
init = mcollections.Collection([], transOffset=skew)
init = mcollections.Collection([], offsets=[], transOffset=skew)

late = mcollections.Collection([])
late.set_offset_transform(skew)
Expand Down

0 comments on commit 27ab206

Please sign in to comment.