Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 92a0843

Browse filesBrowse files
committed
Fixes problem raised in #1431
1 parent 9b4e77d commit 92a0843
Copy full SHA for 92a0843

File tree

Expand file treeCollapse file tree

2 files changed

+17
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-5
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_transform(self):
240240
instance used by this artist.
241241
"""
242242
if self._transform is None:
243-
self.set_transform(IdentityTransform())
243+
self._transform = IdentityTransform()
244244
elif (not isinstance(self._transform, Transform)
245245
and hasattr(self._transform, '_as_mpl_transform')):
246246
self._transform = self._transform._as_mpl_transform(self.axes)

‎lib/matplotlib/tests/test_artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_artist.py
+16-4Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,38 @@ def test_patch_transform_of_none():
1818
ax.set_xlim([1, 3])
1919
ax.set_ylim([1, 3])
2020

21-
#draw an ellipse over data coord (2,2) by specifying device coords
21+
# Draw an ellipse over data coord (2,2) by specifying device coords.
2222
xy_data = (2, 2)
2323
xy_pix = ax.transData.transform_point(xy_data)
2424

25-
# not providing a transform of None puts the ellipse in data coordinates
25+
# Not providing a transform of None puts the ellipse in data coordinates .
2626
e = mpatches.Ellipse(xy_data, width=1, height=1, fc='yellow', alpha=0.5)
2727
ax.add_patch(e)
2828
assert e._transform == ax.transData
2929

30-
# providing a transform of None puts the ellipse in device coordinates
30+
# Providing a transform of None puts the ellipse in device coordinates.
3131
e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
3232
transform=None, alpha=0.5)
33+
assert e.is_transform_set() is True
3334
ax.add_patch(e)
3435
assert isinstance(e._transform, mtrans.IdentityTransform)
3536

36-
# providing an IdentityTransform puts the ellipse in device coordinates
37+
# Providing an IdentityTransform puts the ellipse in device coordinates.
3738
e = mpatches.Ellipse(xy_pix, width=100, height=100,
3839
transform=mtrans.IdentityTransform(), alpha=0.5)
3940
ax.add_patch(e)
4041
assert isinstance(e._transform, mtrans.IdentityTransform)
42+
43+
# Not providing a transform, and then subsequently "get_transform" should
44+
# not mean that "is_transform_set".
45+
e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
46+
alpha=0.5)
47+
intermediate_transform = e.get_transform()
48+
assert e.is_transform_set() is False
49+
ax.add_patch(e)
50+
assert e.get_transform() != intermediate_transform
51+
assert e.is_transform_set() is True
52+
assert e._transform == ax.transData
4153

4254

4355
@cleanup

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.