统计绘图

Matplotlib 数据可视化入门

Ariel Rokem

Data Scientist

为柱状图添加误差线

fig, ax = plt.subplots()

ax.bar("Rowing",
       mens_rowing["Height"].mean(),
       yerr=mens_rowing["Height"].std())

ax.bar("Gymnastics",
       mens_gymnastics["Height"].mean(),
       yerr=mens_gymnastics["Height"].std())

ax.set_ylabel("Height (cm)")

plt.show()
Matplotlib 数据可视化入门

柱状图中的误差线

Matplotlib 数据可视化入门

为折线图添加误差线

fig, ax = plt.subplots()

ax.errorbar(seattle_weather["MONTH"],
            seattle_weather["MLY-TAVG-NORMAL"],
            yerr=seattle_weather["MLY-TAVG-STDDEV"])

ax.errorbar(austin_weather["MONTH"],
            austin_weather["MLY-TAVG-NORMAL"],
            yerr=austin_weather["MLY-TAVG-STDDEV"])

ax.set_ylabel("Temperature (Fahrenheit)")

plt.show()
Matplotlib 数据可视化入门

图中的误差线

Matplotlib 数据可视化入门

添加箱线图

fig, ax = plt.subplots()

ax.boxplot([mens_rowing["Height"], mens_gymnastics["Height"]])
ax.set_xticklabels(["Rowing", "Gymnastics"]) ax.set_ylabel("Height (cm)") plt.show()
Matplotlib 数据可视化入门

解读箱线图

Matplotlib 数据可视化入门

自己试试!

Matplotlib 数据可视化入门

Preparing Video For Download...