-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
203 lines (172 loc) · 5.03 KB
/
plot.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import numpy as np
import csv
import json
import os
import datetime
import matplotlib.pyplot as plt
import seaborn as sb
import shutil
import pprint
pp = pprint.PrettyPrinter(indent=4)
import config
import utils
from constants import *
def move_y(y, off):
return y + (y * 1.4 * off)
def move_x(x, off, len):
return x + (len * 0.015 * off)
def plot_mark(plt, x, y, marker_params, o_x=0, o_y=0, len=360, p=False):
xx = move_x(x, o_x, len)
yy = move_y(y, o_y)
if p:
print(f"{xx}, , {yy}")
plt.plot([xx], [yy], clip_on=False, **marker_params)
def plot_arrow(plt, x, y, x2, y2, color, o_x=0, o_y=0, len=360):
xx = move_x(x, o_x, len)
yy = move_y(y, o_y)
xx2 = x2 - x
yy2 = y2 - y
plt.annotate("", xy=(xx, yy), xytext=(xx2, yy2), textcoords='offset points', rotation=0, size=10,
horizontalalignment='left', verticalalignment="center",
color=color, arrowprops=dict(
arrowstyle="<|-",
alpha=1,
facecolor=color,
edgecolor=color,
lw=2
)
)
# #######################
# VISUAL
# #######################
def plot_relocation_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$I$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 10,
"alpha": 0.5
}
w = 20
xx = x - 3
xx2 = x + w
plot_arrow(plt, xx, y, xx2, y, color_c if changed else color, o_x=0, o_y=0.5, len=360)
def plot_canvas_mark(plt, x, y, changed, color, color_c):
marker_bg = {
"marker": "s",
"markerfacecolor": "#FFFFFF",
"markeredgewidth": 2,
"markeredgecolor": color_c if changed else color,
"markersize": 25,
'linestyle': '-',
"alpha": 1
}
plot_mark(plt, x, y, marker_bg)
# #######################
# CENTER MARK
# #######################
marker_bg = {
"marker": "o",
"markerfacecolor": "#FFFFFF",
"markeredgecolor": "#FFFFFF",
"markersize": 16,
"alpha": 0.5,
}
marker_bg_azure = {
"marker": "o",
"markerfacecolor": "#97f3e5",
"markeredgecolor": "#FFFFFF",
"markersize": 10,
"alpha": 0.5
}
marker_bg_pink = {
"marker": "o",
"markerfacecolor": "#f397a5",
"markeredgecolor": "#FFFFFF",
"markersize": 10,
"alpha": 0.5
}
#
# Mark: INITIAL
#
def plot_initial_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$I$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 10,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg)
plot_mark(plt, x, y, marker_params, o_x, o_y, len)
#
# Mark: TEXT
#
def plot_text_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$T$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 10,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg)
plot_mark(plt, x, y, marker_params, o_x, o_y, len)
#
# Mark: BITMAP
#
def plot_bitmap_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$B$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 10,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg)
plot_mark(plt, x, y, marker_params, o_x, o_y, len)
#
# Mark: NN
#
def plot_nn_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$N$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 10,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg)
plot_mark(plt, x, y, marker_params, o_x, o_y, len)
# #######################
# TOP-LEFT
# #######################
#
# Mark: TEMPORAL
#
def plot_temporal_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$t$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 6,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg_azure, o_x- 0.4, o_y + 0.4)
plot_mark(plt, x , y , marker_params, o_x- 0.4, o_y + 0.4, len, p=False)
# #######################
# TOP-RIGHT
# #######################
#
# Mark: LIKE
#
def plot_like_mark(plt, x, y, changed, color, color_c, o_x=0, o_y=0, len=360):
marker_params = {
"marker": r"$L$",
"markerfacecolor": color_c if changed else color,
"markeredgecolor": color_c if changed else color,
"markersize": 5,
"alpha": 0.9
}
#plot_mark(plt, x, y, marker_bg_pink, o_x + 0.4, o_y + 0.4)
plot_mark(plt, x , y , marker_params, o_x+ 0.5, o_y - 0.2, len, p=False)