我需要根据两个标准绘制此数据集:Churn和Cust_Value。
我可以使用seaborn来做到这一点:
sns.barplot(x="Cust_Value", y="value", hue="Churn", data=merged)
plt.show()
如何将所有变量(值,年龄,重新加载,调用,持续时间,短信,gprs,非活动)添加到与酒吧组相同的图表中?
答案 0 :(得分:1)
对于那种输出我建议使用plotly,
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Bar(
x=DF['Cust_Value'],
y=DF['value'],
name='value'
)
trace2 = go.Bar(
x=DF['Cust_Value'],
y=DF['age'],
name='age'
)
trace3 = go.Bar(
x=DF['Cust_Value'],
y=DF['calls'],
name='calls'
)
data = [trace1, trace2, trace3]
layout = go.Layout(
barmode='group'
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='grouped-bar')
示例输出:
参考:https://plot.ly/python/bar-charts/
希望它有所帮助!如果它支持:)
和平