![](/img/trans.png)
[英]How to add a hue of one categorical column to Seaborn barplot (of each column mean and std)?
[英]seaborn - how to add mean bar to barplot grouped with hue
我的代码如下:
import pandas as pd
import numpy as np
import seaborn as sns
data=[np.random.randint(2018,2020,size=(30)),
np.random.randint(1,13,size=(30)),
np.random.randint(1,101,size=(30)),
np.random.randint(1,101,size=(30))]
cols=['year','month','val','val1']
data=pd.DataFrame(data).T
data.columns=cols
data1=[np.random.randint(1,13,size=(30)),
np.random.randint(1,101,size=(30)),
np.random.randint(1,101,size=(30))]
cols1=['month','val','val1']
data1=pd.DataFrame(data1).T
data1.columns=cols1
sns.barplot(data=data,x='month',y='val',hue='year',ci=False)
sns.barplot(data=data,x='month',y='val',estimator=np.mean,ci=False)
产生条形图,实际上我得到了两个条形图
第二个是每个月的平均值
但我想要一个 plot 每个月包含三列,包括平均条。 你能帮我解决这个问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.