-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpie_chart_plot.py
More file actions
105 lines (56 loc) · 1.62 KB
/
pie_chart_plot.py
File metadata and controls
105 lines (56 loc) · 1.62 KB
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
# -*- coding: utf-8 -*-
"""pie_chart_plot.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1QrbPwOGcHI5dckhpgc3mkuL650FUZqBK
"""
# Commented out IPython magic to ensure Python compatibility.
# %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
data = np.array([35,25,25,15])
plt.pie(data)
plt.show()
mylabels = ['A','B','C','D']
plt.pie(data, labels = mylabels)
plt.show()
explode = [0.0, 0.05, 0.1, 0.15]
plt.pie(data, labels = mylabels, explode = explode)
plt.show()
plt.pie(data, labels = mylabels, explode = explode, shadow = True)
plt.show()
plt.pie(data, labels = mylabels, explode = explode, shadow = True)
plt.legend()
plt.show()
plt.pie(data, labels = mylabels, explode = explode, shadow = True)
plt.legend(title = 'Data : ')
plt.show()
N = 20
theta = np.linspace(0.0, 2*np.pi, N)
r = 10*np.random.rand(N)
plt.subplot(projection = 'polar')
plt.bar(theta, r, bottom = 0.0, color = ['r','g','b'], alpha = 0.2)
plt.show()
r = np.arange(0, 5, 0.2)
theta = 2*np.pi*r
plt.subplot(projection = 'polar')
plt.plot(theta, r)
plt.show()
r = np.arange(0, 5, 0.01)
theta = 2*np.pi*r
plt.subplot(projection = 'polar')
plt.plot(theta, r)
plt.show()
N = 150
r = np.random.rand(N)
theta = 2*np.pi*np.random.rand(N)
size = r * 100
plt.subplot(projection = 'polar')
plt.scatter(theta, r, c = theta, s = size, cmap = 'hsv', alpha = 0.5)
plt.show()
fig = plt.figure()
ax = fig.add_subplot(projection = 'polar')
c = ax.scatter(theta, r, c = theta, s = size, cmap = 'hsv', alpha = 0.5)
ax.set_thetamin(0)
ax.set_thetamax(90)
plt.show()