1
+ import pandas as pd
2
+ import numpy as np
3
+ import matplotlib .pyplot as plt
4
+
5
+ def draw_pie ():
6
+
7
+ series = pd .Series (3 * np .random .rand (4 ), index = ["1" , "2" , "3" , "4" ], name = "series" )
8
+ series .plot .pie (figsize = (6 , 6 ));
9
+ plt .show ()
10
+
11
+
12
+ def draw_pie1 ():
13
+ df = pd .DataFrame (
14
+ 3 * np .random .rand (4 , 2 ), index = ["a" , "b" , "c" , "d" ], columns = ["x" , "y" ])
15
+ df .plot .pie (subplots = True , figsize = (8 , 4 ), legend = False )
16
+ plt .show ()
17
+
18
+ def draw_pie2 ():
19
+ series = pd .Series (3 * np .random .rand (4 ), index = ["1" , "2" , "3" , "4" ], name = "series" )
20
+ series .plot .pie (
21
+ labels = ["A" , "B" , "C" , "D" ],
22
+ colors = ["r" , "g" , "b" , "c" ],
23
+ autopct = "%.2f" ,
24
+ fontsize = 20 ,
25
+ figsize = (6 , 6 ),)
26
+ plt .show ()
27
+
28
+ def draw_pie3 ():
29
+ series = pd .Series ([0.1 ] * 4 , index = ["a" , "b" , "c" , "d" ], name = "series2" )
30
+ series .plot .pie (figsize = (6 , 6 ))
31
+ plt .show ()
32
+
33
+ import pandas as pd
34
+ import numpy as np
35
+ import matplotlib .pyplot as plt
36
+ from pandas .plotting import scatter_matrix
37
+ def draw_pie4 ():
38
+
39
+ df = pd .DataFrame (np .random .randn (1000 , 4 ), columns = ["a" , "b" , "c" , "d" ])
40
+
41
+ scatter_matrix (df , alpha = 0.2 , figsize = (6 , 6 ), diagonal = "kde" )
42
+ plt .show ()
43
+
44
+ if __name__ == '__main__' :
45
+ draw_pie4 ()
0 commit comments