python 数据可视化02

一.学习内容
(1)绘制堆积图 stackplot()

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(6)
y1= np.array([1,4,3,5,6,7])
y2= np.array([1,3,4,2,7,6])
y3=np.array([3,4,3,6,5,5])
plt.stackplot(x,y1,y2,y3)
plt.title("2020080603043")
plt.show()

python 数据可视化02_第1张图片

(2绘制直方图 hist()

scorce = np.random.randint(0,100,50)
plt.hist(scorce,bins=8,histtype='stepfilled')
plt.title("2020080603043")
plt.show()

python 数据可视化02_第2张图片
(3)绘制饼图和圆环图 pie()

data = np.array([20,50,10,15,30,55])
pie_labels =np.array(['A','B','C','D','E','F'])
plt.pie(data,radius=1.5 , labels=pie_labels ,autopct='%3.1f%%')
plt.title("2020080603043")
plt.show()


data = np.array([20,50,10,15,30,55])
pie_labels =np.array(['A','B','C','D','E','F'])
plt.pie(data,radius=1.5 , wedgeprops={'width': 0.7} ,labels=pie_labels ,autopct='%3.1f%%', pctdistance=0.75 )
plt.title("2020080603043")
plt.show()




import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False
kinds=['购物','人情来往','餐饮美食','通信物流','生活日用','交通出行','休闲娱乐','其他']
money_scale=[800/3000, 100/3000,1000/3000,200/3000,300/3000,200/3000,200/3000,200/3000]
dev_position=[0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]
plt.pie(money_scale,labels=kinds,autopct='%3.1f%%', shadow=True, explode=dev_position,startangle=90)
plt.title("2020080603043")
plt.show()



python 数据可视化02_第3张图片
python 数据可视化02_第4张图片
python 数据可视化02_第5张图片

(4)绘制散点图和气泡图scatter()

import numpy as np
import matplotlib.pyplot as plt
num =50
x= np.random.rand(num)
y=np.random.rand(num)
plt.scatter(x,y)
plt.title("2020080603043")
plt.show()


num =50
x= np.random.rand(num)
y=np.random.rand(num)
area=(30* np.random.rand(num))**2
plt.scatter(x,y,s=area)
plt.title("2020080603043")
plt.show()

python 数据可视化02_第6张图片
python 数据可视化02_第7张图片
(5)绘制箱型图boxplot()

import numpy as np
import matplotlib.pyplot as plt
data = np .random.rand(100)
plt.boxplot(data ,meanline=True , widths=0.3 ,patch_artist=True , showfliers=False)
plt.title("2020080603043")
plt.show()

python 数据可视化02_第8张图片
(6)绘制雷达图 polar()
(7)绘制误差棒图 errorbar()

import numpy as np
import matplotlib.pyplot as plt
x= np.arange(5)
y=(25,32,34,20,25)
y_offset = (3,4,2,3,3)
plt.errorbar(x,y,yerr=y_offset,capsize=3,capthick=2)
plt.title("2020080603043")
plt.show()

python 数据可视化02_第9张图片

你可能感兴趣的:(java,服务器,开发语言)