[英]Plot Multiple Y axis + 'hue' from Seaborn
Hello World ,你好世界,
Below is an example of my df下面是我的 df 的一个例子
df
Date Name x1 x2 x3 x4
01/01/16 aa 10 15 20 11
01/01/16 bb 10 10 50 14
02/01/16 aa 12 30 17 25
02/01/16 bb 17 10 14 25
... ...
Question:题:
How can I plot on:我怎样才能 plot 上:
What I have done so far, gives me the following output到目前为止我所做的,给了我以下 output
g= df.plot(x="date", y=['x1', 'x2', 'x3', 'x4'], figsize=(30,10), kind='bar')
The expected output will be the same as above but with the Name as title.预期的 output 与上面相同,但名称为标题。
I thought of hue argument like in seaborn but not working with pandas.plot我想到了 seaborn 中的 hue 参数,但没有使用 pandas.plot
Thanks for everyone helping!感谢大家的帮助!
Try this on your dataframe:在您的 dataframe 上试试这个:
df = df.melt(id_vars=['Date', 'Name'], value_name='values',
var_name='variables')
sns.catplot(data=df, x='Date', y='values', hue='variables', col='Name',
kind="bar")
with dataframe melt as per JK, some chart options:根据 JK 的 dataframe 熔化,一些图表选项:
import seaborn as sns
sns.barplot(x="Date", y='values', hue='Name', data=df, ci=None)
sns.catplot(data=df, x='Date', y='values', hue='Name', kind="bar", ci=None)
the ci removes the confidence interval draw if you do not need it如果不需要,ci 会删除置信区间绘制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.