| 261 | |
| 262 | @image_comparison(['hatching'], remove_text=True, style='default') |
| 263 | def test_hatching(): |
| 264 | # Remove legend texts when this image is regenerated. |
| 265 | fig, ax = plt.subplots() |
| 266 | |
| 267 | # Patches |
| 268 | patch = plt.Rectangle((0, 0), 0.3, 0.3, hatch='xx', |
| 269 | label='Patch\ndefault color\nfilled') |
| 270 | ax.add_patch(patch) |
| 271 | patch = plt.Rectangle((0.33, 0), 0.3, 0.3, hatch='||', edgecolor='C1', |
| 272 | label='Patch\nexplicit color\nfilled') |
| 273 | ax.add_patch(patch) |
| 274 | patch = plt.Rectangle((0, 0.4), 0.3, 0.3, hatch='xx', fill=False, |
| 275 | label='Patch\ndefault color\nunfilled') |
| 276 | ax.add_patch(patch) |
| 277 | patch = plt.Rectangle((0.33, 0.4), 0.3, 0.3, hatch='||', fill=False, |
| 278 | edgecolor='C1', |
| 279 | label='Patch\nexplicit color\nunfilled') |
| 280 | ax.add_patch(patch) |
| 281 | |
| 282 | # Paths |
| 283 | ax.fill_between([0, .15, .3], [.8, .8, .8], [.9, 1.0, .9], |
| 284 | hatch='+', label='Path\ndefault color') |
| 285 | ax.fill_between([.33, .48, .63], [.8, .8, .8], [.9, 1.0, .9], |
| 286 | hatch='+', edgecolor='C2', label='Path\nexplicit color') |
| 287 | |
| 288 | ax.set_xlim(-0.01, 1.1) |
| 289 | ax.set_ylim(-0.01, 1.1) |
| 290 | ax.legend(handlelength=4, handleheight=4) |
| 291 | |
| 292 | |
| 293 | def test_legend_remove(): |