爬虫四张数据图加源码
散点图
import numpy as np
import matplotlib.pyplot as plt
height=[161,170,182,175,173,165]
weight=[50,58,80,70,69,55]
plt.scatter(height,weight)
# 显示数据图
plt.show()
折线图
import numpy as np
import matplotlib.pyplot as plt
# 生成一组等区间数值
x=np.linspace(-10,10,100)
y=x**2
plt.plot(x,y)
plt.show()
条型图
import numpy as np
import matplotlib.pyplot as plt
N=5
y=[20,10,30,25,15]
index = np.arange(N)
p1 = plt.bar(x=index, height=y,width=0.5,bottom=100,color='red')
plt.show()
直方图
import numpy as np
import matplotlib.pyplot as plt
mu = 100 # mean of distribution
sigma = 20 # standard deviation of distribution
x = mu + sigma * np.random.randn(2000)
plt.h