forked from matplotlib/data-prototype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_patch.py
70 lines (59 loc) · 1.61 KB
/
simple_patch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
====================
Simple patch artists
====================
Draw two fully specified rectangle patches.
Demonstrates :class:`.patches.RectangleWrapper` using
:class:`.containers.ArrayContainer`.
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from data_prototype.containers import ArrayContainer
from data_prototype.artist import CompatibilityAxes
from data_prototype.patches import Rectangle
cont1 = ArrayContainer(
lower_left_x=np.array(-3),
lower_left_y=np.array(0),
upper_right_x=np.array(-1),
upper_right_y=np.array(3),
edgecolor=np.array([0, 0, 0]),
facecolor="green",
linewidth=3,
linestyle="-",
antialiased=np.array([True]),
fill=np.array([True]),
capstyle=np.array(["round"]),
joinstyle=np.array(["miter"]),
alpha=np.array(0.5),
)
cont2 = ArrayContainer(
lower_left_x=0,
lower_left_y=np.array(1),
upper_right_x=np.array(2),
upper_right_y=np.array(5),
angle=30,
rotation_point_x=np.array(1),
rotation_point_y=np.array(3.5),
edgecolor=np.array([0.5, 0.2, 0]),
facecolor="red",
linewidth=6,
linestyle="-",
antialiased=np.array([True]),
fill=np.array([True]),
capstyle=np.array(["round"]),
joinstyle=np.array(["miter"]),
)
fig, nax = plt.subplots()
ax = CompatibilityAxes(nax)
nax.add_artist(ax)
nax.set_xlim(-5, 5)
nax.set_ylim(0, 5)
rect = mpatches.Rectangle((4, 1), 2, 3, linewidth=6, edgecolor="black", angle=30)
nax.add_artist(rect)
rect1 = Rectangle(cont1, {})
rect2 = Rectangle(cont2, {})
ax.add_artist(rect1)
ax.add_artist(rect2)
nax.set_aspect(1)
plt.show()