带有错误带的Python分类图

时间:2017-01-12 16:28:56

标签: python matplotlib plot seaborn categorical-data

我需要绘制以下数据的图表,其中x轴为year_week,y轴为test_duration,每个运算符为不同的系列。一周内同一运营商可能有多个数据点。我需要在每个系列周围显示标准偏差带。

data = pd.DataFrame({'year_week':[1601,1602,1603,1604,1604,1604],
'operator':['jones','jack','john','jones','jones','jack'],
'test_duration':[10,12,43,7,23,9]})

打印为:

enter image description here

我看过seaborn,matplotlib和pandas,但我找不到解决方案。

1 个答案:

答案 0 :(得分:1)

可能你正在寻找seaborn pointplot

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

data = pd.DataFrame({'year_week':[1601,1602,1603,1604,1604,1604],
'operator':['jones','jack','john','jones','jones','jack'],
'test_duration':[10,12,43,7,23,9]})

sns.pointplot(x="year_week", y="test_duration", hue="operator", data=data)

plt.show()

enter image description here