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

Skip to content

Commit 088b017

Browse files
committed
Created hatches_styles.py
1 parent 0df677a commit 088b017

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
==========
3+
Hatches Styles Demo
4+
==========
5+
6+
Hatching (pattern filled polygons) is supported currently in the PS,
7+
PDF, SVG and Agg backends only.
8+
"""
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
from matplotlib.patches import Rectangle
12+
13+
fig, ax = plt.subplots()
14+
15+
x = np.repeat([1, 4, 7, 10, 13], 2)
16+
y = np.tile([2, 5], 5)
17+
18+
pos = np.array(list(zip(x, y)))
19+
text_pos = pos + [0.9, -0.5]
20+
21+
hashes = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
22+
23+
for h in range(len(hashes)):
24+
ax.add_patch(Rectangle(pos[h], 2, 2, fill=False, hatch=hashes[h]))
25+
ax.text(text_pos[h][0],text_pos[h][1], hashes[h], fontsize=15)
26+
27+
plt.axis('equal')
28+
plt.axis('off')
29+
plt.tight_layout()
30+
31+
plt.show()
32+
33+
#############################################################################
34+
#
35+
# ------------
36+
#
37+
# References
38+
# """"""""""
39+
#
40+
# The use of the following functions, methods, classes and modules is shown
41+
# in this example:
42+
43+
import matplotlib
44+
matplotlib.patches
45+
matplotlib.patches.Rectangle
46+
matplotlib.axes.Axes.add_patch
47+
matplotlib.axes.Axes.text

0 commit comments

Comments
 (0)