Skip to content

Commit 018d4c4

Browse files
committed
add code
1 parent 01497e1 commit 018d4c4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

chaoxi/Pandas2/pandas_example1.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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()

chaoxi/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Python技术 公众号文章代码库
99

1010
## 实例代码
1111

12+
[神器 Pandas 绘图大全(上)!](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/Pandas2) 神器 Pandas 绘图大全(中)!
13+
1214
[神器 Pandas 绘图大全(上)!](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/Pandas1) 神器 Pandas 绘图大全(上)!
1315

1416
[神器-可视化分析之Basemap实战详解(二)](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/BaseMap) 神器-可视化分析之Basemap实战详解(二)

0 commit comments

Comments
 (0)