-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
41 lines (33 loc) · 1.1 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
import matplotlib.pyplot as plt
from data_keys import renda_colors
def pie(df, labels, title, legend, bbox_to_anchor):
ax = df \
.value_counts() \
.sort_index() \
.rename(labels) \
.plot.pie(figsize=(12.8, 8),
colors=renda_colors,
labels=[''] * len(labels),
ylabel='',
autopct='%.2f%%',
textprops={'backgroundcolor': (1, 1, 1, 0.5), 'color': '#303030'})
mid = (ax.figure.subplotpars.right + ax.figure.subplotpars.left) / 2
plt.title(title,
fontsize=20,
ha='center',
va='baseline',
x=mid)
plt.suptitle(f'Quantidade total de alunos: {df.count()}',
fontsize=14,
ha='center',
va='baseline',
x=mid,
y=.85)
ax.legend(title=legend,
labels=labels.values(),
labelcolor='#303030',
loc="center left",
bbox_to_anchor=bbox_to_anchor)
plt.tight_layout()
plt.show()
plt.close()