8000 Added a new test: The hatch of the original patches should be used fo… · matplotlib/matplotlib@b7e9588 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7e9588

Browse files
committed
Added a new test: The hatch of the original patches should be used for a PatchCollection when match_original is true.
1 parent 43f16a0 commit b7e9588

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from matplotlib.backend_bases import MouseEvent
1111
import matplotlib.collections as mcollections
1212
import matplotlib.colors as mcolors
13+
import matplotlib.patches as mpatches
1314
import matplotlib.transforms as mtransforms
1415
from matplotlib.collections import (Collection, LineCollection,
1516
EventCollection, PolyCollection)
@@ -1117,3 +1118,25 @@ def test_set_offset_units():
11171118
off0 = sc.get_offsets()
11181119
sc.set_offsets(list(zip(y, d)))
11191120
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

Comments
 (0)
0