-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_matplotlib.py
More file actions
26 lines (20 loc) · 857 Bytes
/
test_matplotlib.py
File metadata and controls
26 lines (20 loc) · 857 Bytes
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
import matplotlib.pyplot as plt
import numpy as np
def absolute_value(val):
a = numpy.round(val/100.*sizes.sum(), 0)
return a
def func(pct, allvals):
absolute = int(pct/100.*np.sum(allvals))
return "{:d} hits".format(absolute)
def main():
labels = ['Python', 'C++', 'Ruby', 'Java', 'Fortran', 'Basic', 'Foo', 'Bar']
sizes = [215, 130, 245, 210, 90, 400, 257, 37]
print(type(labels))
#colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
#explode = (0.1, 0, 0, 0) # explode 1st slice
#plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=140)
plt.pie(sizes, labels=labels, autopct=lambda pct: func(pct, sizes))
plt.axis('equal')
plt.savefig('C:/temp/plot7.png')
if __name__ == "__main__":
main()