()
| 19 | |
| 20 | |
| 21 | def 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 | |
| 63 | def test_collection_transform_of_none(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…