8000 Changed filename and added constrained_layout and spellchecked · matplotlib/matplotlib@0544237 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0544237

Browse files
committed
Changed filename and added constrained_layout and spellchecked
1 parent f7d1984 commit 0544237

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

examples/shapes_and_collections/hatches_styles.py renamed to examples/shapes_and_collections/hatch_style_reference.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
===================
3-
Hatches Styles Demo
4-
===================
2+
=====================
3+
Hatch style reference
4+
=====================
55
66
Hatching (pattern filled polygons) is supported currently in the PS,
77
PDF, SVG and Agg backends only.
@@ -10,25 +10,19 @@
1010
import numpy as np
1111
from matplotlib.patches import Rectangle
1212

13-
fig, ax = plt.subplots()
13+
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(10, 5))
1414

15-
x = np.repeat([1, 4, 7, 10, 13], 2)
16-
y = np.tile([2, 5], 5)
15+
hatches = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
1716

18-
pos = np.column_stack((x, y))
19-
text_pos = pos + [0.9, -0.5]
2017

21-
hashes = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
18+
def hatches_plot(ax, h):
19+
ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, hatch=h))
20+
ax.set_title(f"' {h} '")
21+
ax.axis('equal')
22+
ax.axis('off')
2223

23-
for h, p, t in zip(hashes, pos, text_pos):
24-
ax.add_patch(Rectangle(p, 2, 2, fill=False, hatch=h))
25-
ax.text(t[0], t[1], h, fontsize=15)
26-
27-
ax.axis('equal')
28-
ax.axis('off')
29-
fig.tight_layout()
30-
31-
plt.show()
24+
for ax, h in zip(axs.flat, hatches):
25+
hatches_plot(ax, h)
3226

3327
#############################################################################
3428
#

0 commit comments

Comments
 (0)
0