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

Skip to content

Commit 6d7bcf4

Browse files
committed
Update hatch style reference
Corrected figsize, removed repeated function, and fixed repeated hatches.
1 parent 5ea5c4b commit 6d7bcf4

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

examples/shapes_and_collections/hatch_style_reference.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as plt
1010
from matplotlib.patches import Rectangle
1111

12-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(9, 4.5))
12+
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
1313

1414
hatches = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
1515

@@ -26,33 +26,19 @@ def hatches_plot(ax, h):
2626
###############################################################################
2727
# Hatching patterns can be repeated to increase the density.
2828

29-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(9, 4.5))
29+
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
3030

3131
hatches = ['//', '\\\\', '||', '--', '++', 'xx', 'oo', 'OO', '..', '**']
3232

33-
34-
def hatches_plot(ax, h):
35-
ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, hatch=h))
36-
ax.text(1, -0.5, f"' {h} '", size=15, ha="center")
37-
ax.axis('equal')
38-
ax.axis('off')
39-
4033
for ax, h in zip(axs.flat, hatches):
4134
hatches_plot(ax, h)
4235

4336
###############################################################################
4437
# Hatching patterns can be combined to create additional patterns.
4538

46-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(9, 4.5))
39+
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
4740

48-
hatches = ['//', '\\\\', '||', '--', '++', 'xx', 'oo', 'OO', '..', '**']
49-
50-
51-
def hatches_plot(ax, h):
52-
ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, hatch=h))
53-
ax.text(1, -0.5, f"' {h} '", size=15, ha="center")
54-
ax.axis('equal')
55-
ax.axis('off')
41+
hatches = ['/o', '\\|', '|*', '-\\', '+o', 'x*', 'o-', 'O|', 'O.', '*-']
5642

5743
for ax, h in zip(axs.flat, hatches):
5844
hatches_plot(ax, h)

0 commit comments

Comments
 (0)