Matplotlib常见的图表类型
折线图
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()
散点图
plt.scatter(x, y)
plt.show()
柱状图
plt.bar(x, height)
plt.show()
水平柱状图
plt.barh(x, width)
plt.show()
直方图
plt.hist(data, bins=10)
plt.show()
箱线图
plt.boxplot(data)
plt.show()
饼图
plt.pie(sizes, labels=labels)
plt.show()
面积图
plt.fill_between(x, y1, y2)
plt.show()
热图
import seaborn as sns
sns.heatmap(data)
plt.show()
误差条形图
plt.errorbar(x, y, yerr=errors)
plt.show()
条形图
plt.bar(x, y1)
plt.bar(x, y2, bottom=y1)
plt.show()
极坐标图
plt.polar(theta, r)
plt.show()
步长图
plt.step(x, y)
plt.show()
等值线图
plt.contour(X, Y, Z)
plt.show()
3D图
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z)
plt.show()
流线图
plt.streamplot(X, Y, U, V)
plt.show()