MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_patch_transform_of_none

Function test_patch_transform_of_none

lib/matplotlib/tests/test_artist.py:21–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19
20
21def test_patch_transform_of_none():
22 # tests the behaviour of patches added to an Axes with various transform
23 # specifications
24
25 ax = plt.axes()
26 ax.set_xlim(1, 3)
27 ax.set_ylim(1, 3)
28
29 # Draw an ellipse over data coord (2, 2) by specifying device coords.
30 xy_data = (2, 2)
31 xy_pix = ax.transData.transform(xy_data)
32
33 # Not providing a transform of None puts the ellipse in data coordinates .
34 e = mpatches.Ellipse(xy_data, width=1, height=1, fc='yellow', alpha=0.5)
35 ax.add_patch(e)
36 assert e._transform == ax.transData
37
38 # Providing a transform of None puts the ellipse in device coordinates.
39 e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
40 transform=None, alpha=0.5)
41 assert e.is_transform_set()
42 ax.add_patch(e)
43 assert isinstance(e._transform, mtransforms.IdentityTransform)
44
45 # Providing an IdentityTransform puts the ellipse in device coordinates.
46 e = mpatches.Ellipse(xy_pix, width=100, height=100,
47 transform=mtransforms.IdentityTransform(), alpha=0.5)
48 ax.add_patch(e)
49 assert isinstance(e._transform, mtransforms.IdentityTransform)
50
51 # Not providing a transform, and then subsequently "get_transform" should
52 # not mean that "is_transform_set".
53 e = mpatches.Ellipse(xy_pix, width=120, height=120, fc='coral',
54 alpha=0.5)
55 intermediate_transform = e.get_transform()
56 assert not e.is_transform_set()
57 ax.add_patch(e)
58 assert e.get_transform() != intermediate_transform
59 assert e.is_transform_set()
60 assert e._transform == ax.transData
61
62
63def test_collection_transform_of_none():

Callers

nothing calls this directly

Calls 7

add_patchMethod · 0.80
is_transform_setMethod · 0.80
axesMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
transformMethod · 0.45
get_transformMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…