-
-
Notifications
You must be signed in to change notification settings - Fork 401
/
Copy pathreference-adjustments.py
128 lines (96 loc) · 4.21 KB
/
reference-adjustments.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: BSD
# ----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.collections import PatchCollection
fig = plt.figure(figsize=(4.25, 4.25 * 95/115))
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1,
xlim=(0-5,100+10), ylim=(-10,80+5), xticks=[], yticks=[])
box = mpatches.FancyBboxPatch(
(0,0), 100, 83, mpatches.BoxStyle("Round", pad=0, rounding_size=2),
linewidth=1., facecolor="0.9", edgecolor="black")
ax.add_artist(box)
box = mpatches.FancyBboxPatch(
(0,0), 100, 75, mpatches.BoxStyle("Round", pad=0, rounding_size=0),
linewidth=1., facecolor="white", edgecolor="black")
ax.add_artist(box)
box = mpatches.Rectangle(
(5,5), 45, 30, zorder=10,
linewidth=1.0, facecolor="white", edgecolor="black")
ax.add_artist(box)
box = mpatches.Rectangle(
(5,40), 45, 30, zorder=10,
linewidth=1.0, facecolor="white", edgecolor="black")
ax.add_artist(box)
box = mpatches.Rectangle(
(55,5), 40, 65, zorder=10,
linewidth=1.0, facecolor="white", edgecolor="black")
ax.add_artist(box)
# Window button
X, Y = [5,10,15], [79,79,79]
plt.scatter(X, Y, s=75, zorder=10,
edgecolor="black", facecolor="white", linewidth=1)
# Window size extension
X, Y = [0, 0], [0, -8]
plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False)
X, Y = [100, 100], [0, -8]
plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False)
X, Y = [100, 108], [0, 0]
plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False)
X, Y = [100, 108], [75, 75]
plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False)
def ext_arrow(p0,p1,p2,p3):
p0, p1 = np.asarray(p0), np.asarray(p1)
p2, p3 = np.asarray(p2), np.asarray(p3)
ax.arrow(*p0, *(p1-p0), zorder=20, linewidth=0,
length_includes_head=True, width=.4,
head_width=2, head_length=2, color="black")
ax.arrow(*p3, *(p2-p3), zorder=20, linewidth=0,
length_includes_head=True, width=.4,
head_width=2, head_length=2, color="black")
plt.plot([p1[0],p2[0]], [p1[1],p2[1]], linewidth=.9, color="black")
def int_arrow(p0,p1):
p0, p1 = np.asarray(p0), np.asarray(p1)
ax.arrow(*((p0+p1)/2), *((p1-p0)/2), zorder=20, linewidth=0,
length_includes_head=True, width=.4,
head_width=2, head_length=2, color="black")
ax.arrow(*((p0+p1)/2), *(-(p1-p0)/2), zorder=20, linewidth=0,
length_includes_head=True, width=.4,
head_width=2, head_length=2, color="black")
x = 0
y = 10
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
ax.text(x+9.5, y, "left", ha="left", va="center", size="x-small", zorder=20)
x += 50
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
ax.text(x-4.5, y, "wspace", ha="right", va="center", size="x-small", zorder=20)
x += 45
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
ax.text(x-4.5, y, "right", ha="right", va="center", size="x-small", zorder=20)
y = 0
x = 25
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
ax.text(x, y+9.5, "bottom", ha="center", va="bottom", size="x-small", zorder=20)
y += 35
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
ax.text(x, y-4.5, "hspace", ha="center", va="top", size="x-small", zorder=20)
y += 35
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
ax.text(x, y-4.5, "top", ha="center", va="top", size="x-small", zorder=20)
int_arrow((0,-5), (100,-5))
ax.text(50, -5, "figure width", backgroundcolor="white", zorder=30,
ha="center", va="center", size="x-small")
int_arrow((105,0), (105,75))
ax.text(105, 75/2, "figure height", backgroundcolor="white", zorder=30,
rotation = "vertical", ha="center", va="center", size="x-small")
int_arrow((55,62.5), (95,62.5))
ax.text(75, 62.5, "axes width", backgroundcolor="white", zorder=30,
ha="center", va="center", size="x-small")
int_arrow((62.5,5), (62.5,70))
ax.text(62.5, 35, "axes height", backgroundcolor="white", zorder=30,
rotation = "vertical", ha="center", va="center", size="x-small")
plt.show()