Merge pull request '数据可视化' (#6) from 盘荣博 into main

main
p3itgm2rp 4 months ago
commit a1f852b393

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 824 KiB

@ -25,4 +25,4 @@ nx.draw_networkx_edge_labels(G,pos,edge_labels=w)#绘制标签
path_edges=list(zip(p,p[1:])) path_edges=list(zip(p,p[1:]))
print(type(path_edges),"\npath_edges=",path_edges) print(type(path_edges),"\npath_edges=",path_edges)
nx.draw_networkx_edges(G,pos,edgelist=path_edges,edge_color="r",width=1) nx.draw_networkx_edges(G,pos,edgelist=path_edges,edge_color="r",width=1)
plt.savefig("figure10_9.png");plt.show() plt.savefig("figure10_9.png",dpi=1000);plt.show()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

@ -1,9 +1,42 @@
import pandas as pd import pandas as pd
from scipy.stats import zscore
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from matplotlib.pyplot import ylabel
df = pd.read_excel("棉花产量论文作业的数据.xlsx") df = pd.read_excel("棉花产量论文作业的数据.xlsx")
plt.plot(df["年份"],df["单产"]) # plt.plot(df["年份"],df["单产"])
plt.rcParams['font.sans-serif']="SimHei" plt.rcParams['font.sans-serif']="SimHei"
plt.ylabel('单产') # plt.rcParams['size'] =10
plt.xlabel('年份') # plt.ylabel('单产')
plt.show() # plt.xlabel('年份')
print(df)
# print(df)
d = df.to_numpy()[:,1:]
print(d)
plt.subplot(4,1,1)
plt.scatter(d[:,:1],d[:,1:2],c='r')
ylabel('原始数据'),plt.title("单产和种子费用的关系")
#公式调用标准化,遵守标准正态分布
data = zscore(d)
print(data)
plt.subplot(4,1,2)
plt.scatter(data[:,:1],data[:,1:2],c='b',)
ylabel('zscore')
print(d.max(axis=0))
print(d.std(axis=0))
print(d.mean(axis=0))
#手写标准正态分布
data1=(d-d.mean(axis=0))/d.std(axis=0)
print(data1)
plt.subplot(4,1,3)
plt.scatter(data1[:,:1],data1[:,1:2],c='y')
ylabel('手写标准正态分布')
data2=(d-d.min(axis=0))/(d.max(axis=0)-d.min(axis=0))
plt.subplot(4,1,4)
plt.scatter(data2[:,:1],data2[:,1:2],c='g')
plt.xlabel('压缩到0~1')
print(data==data1)
plt.savefig("shuju.jpg",dpi=2000)
plt.show()
Loading…
Cancel
Save