Skip to content

Ignore transOffset if no offsets passed to Collection #21550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2021
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
4 changes: 4 additions & 0 deletions doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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