Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4df10ff

Browse files
authored
Merge pull request #17884 from forrestm/hatch_marker_styles
Created Hatch marker styles Demo for Example Gallery
2 parents db3ecd2 + 2c306f3 commit 4df10ff

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ per-file-ignores =
226226
examples/shapes_and_collections/ellipse_demo.py: E402
227227
examples/shapes_and_collections/fancybox_demo.py: E402
228228
examples/shapes_and_collections/hatch_demo.py: E402
229+
examples/shapes_and_collections/hatch_style_reference.py: E402
229230
examples/shapes_and_collections/line_collection.py: E402
230231
examples/shapes_and_collections/marker_path.py: E402
231232
examples/shapes_and_collections/patch_collection.py: E402
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
=====================
3+
Hatch style reference
4+
=====================
5+
6+
Hatching (pattern filled polygons) is currently supported in the backends
7+
PS, PDF, SVG and Agg. The backends OSX, WX and Cairo ignore hatching.
8+
"""
9+
import matplotlib.pyplot as plt
10+
from matplotlib.patches import Rectangle
11+
12+
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(10, 5))
13+
14+
hatches = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
15+
16+
17+
def hatches_plot(ax, h):
18+
ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, hatch=h))
19+
ax.text(1, -0.5, f"' {h} '", size=15, ha="center")
20+
ax.axis('equal')
21+
ax.axis('off')
22+
23+
for ax, h in zip(axs.flat, hatches):
24+
hatches_plot(ax, h)
25+
26+
#############################################################################
27+
#
28+
# ------------
29+
#
30+
# References
31+
# """"""""""
32+
#
33+
# The use of the following functions, methods, classes and modules is shown
34+
# in this example:
35+
36+
import matplotlib
37+
matplotlib.patches
38+
matplotlib.patches.Rectangle
39+
matplotlib.axes.Axes.add_patch
40+
matplotlib.axes.Axes.text

0 commit comments

Comments
 (0)