|
10 | 10 | from matplotlib.backend_bases import MouseEvent
|
11 | 11 | import matplotlib.collections as mcollections
|
12 | 12 | import matplotlib.colors as mcolors
|
| 13 | +import matplotlib.patches as mpatches |
13 | 14 | import matplotlib.transforms as mtransforms
|
14 | 15 | from matplotlib.collections import (Collection, LineCollection,
|
15 | 16 | EventCollection, PolyCollection)
|
@@ -1117,3 +1118,25 @@ def test_set_offset_units():
|
1117 | 1118 | off0 = sc.get_offsets()
|
1118 | 1119 | sc.set_offsets(list(zip(y, d)))
|
1119 | 1120 | np.testing.assert_allclose(off0, sc.get_offsets())
|
| 1121 | + |
| 1122 | + |
| 1123 | +@check_figures_equal(extensions=['png']) |
| 1124 | +def test_patch_collection_keeps_hatch(fig_test, fig_ref): |
| 1125 | + # When creating a PatchCollection, the hatch of the original patches should |
| 1126 | + # be used if match_original == True. |
| 1127 | + ax = fig_test.subplots() |
| 1128 | + patches = [ |
| 1129 | + mpatches.Rectangle((0, 0), 0.2, .2, hatch="/"), |
| 1130 | + mpatches.Rectangle((0.4, 0.4), 0.2, .2, hatch="/") |
| 1131 | + ] |
| 1132 | + collection = mcollections.PatchCollection(patches, match_original=True) |
| 1133 | + ax.add_collection(collection) |
| 1134 | + |
| 1135 | + ax = fig_ref.subplots() |
| 1136 | + patches = [ |
| 1137 | + mpatches.Rectangle((0, 0), 0.2, .2), |
| 1138 | + mpatches.Rectangle((0.4, 0.4), 0.2, .2) |
| 1139 | + ] |
| 1140 | + collection = mcollections.PatchCollection(patches, match_original=False, |
| 1141 | + hatch="/") |
| 1142 | + ax.add_collection(collection) |
0 commit comments