-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot.py
45 lines (37 loc) · 1.6 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
# Import
import matplotlib.pyplot as plt
class Plot:
def __init__(self, data, dates, title, ylbl, xlbl, start=None, end=None):
self.data = data
self.dates = dates
ticks = [i for i, item in enumerate(self.dates) if item.endswith("12")]
self.start = start
self.end = end
plt.style.use('fivethirtyeight')
self.fig, self.ax = plt.subplots()
self.ax.set(title=title, ylabel=ylbl, xlabel=xlbl, xticks=ticks)
plt.subplots_adjust(right=0.82, bottom=0.17)
self.annotations = []
def draw(self):
for row in self.data:
if row[1] == "NOT IN SERVER":
row[1] = "000000"
self.ax.plot(self.dates, row[3:(len(row))], linewidth=2.0, color=row[1])
self.annotations.append([row[-1], row[0], row[2], row[1]]) # Add a list containing [total xp, name, icon, color] to the list annotations
plt.xticks(rotation=70)
def annotate(self):
heights = [350]
for index, item in enumerate(sorted(self.annotations, key=lambda x: x[0])):
height = item[0]
if height - heights[-1] <= 350:
height = heights[-1] + 350
heights.append(height)
# self.ax.annotate(getimg(item[2]), )
self.ax.annotate(item[1], (0.98, height), xycoords=('axes fraction', 'data'), color=item[3], va='center', size='small')
self.annotate_image()
def annotate_image(self):
pass
def show(self):
plt.show()
def save(self, name):
self.fig.savefig(name, bbox_inches='tight')