-
Notifications
You must be signed in to change notification settings - Fork 4
/
PieChart.py
28 lines (21 loc) · 879 Bytes
/
PieChart.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
# Generate pie chart
def Generate_Pie(Detailed_list, Threshold, index, fig, title, textSize):
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import tkinter
# Count values below and over threshold
count_under = 0
count_over = 0
for element in Detailed_list:
if int(element) < int(Threshold):
count_under+=1
else:
count_over+=1
# Generate a pie chart with the count over and under threshold. Blue for over and yellow for the values bellow.
ax = fig.add_subplot(2,2,index)
ax.pie([count_over,count_under], colors=['blue', 'orange'])
ax.axis('equal')
ax.set_title(str(title), fontsize=textSize)
ax.legend([str(count_over) +' bp. > ' + str(int(Threshold)) +'X', str(count_under) + ' bp. < '+ str(int(Threshold)) + 'X'], loc='lower center', bbox_to_anchor=(0.5, 0), fontsize='xx-small')
return fig