matplotlib折线图添加子组X轴标签

时间:2018-11-03 17:25:13

标签: python matplotlib

我想将子组标签(来自图例)添加到下图的轴上。我在下面添加了想要的结果。我怎么做?我不确定Google该怎么做...谢谢

图:总体和-按周数/年的点击次数

sns.set(style="ticks")
pd.pivot_table(df,index=['week_number'],columns=['month','year'],values=['clicks'],aggfunc=np.sum).plot(kind=('line'),legend=True,title=('Clicks by Week/ Month over Time'),figsize=(15, 8))
plt.legend()
plt.ylabel('Total Clicks')
plt.xlabel('Week Number, Month')
plt.show();

enter image description here

编辑:添加了数据

event_id    event_date  week_number holiday month   day year    pub_organization_id clicks  sales   conversion_rate sale_amount_usd pub_commission_usd
0   11  1/1/13  1   New Year's Day  January 1   2013    299 146 1   0.006849    18.00   0.18
1   241 1/1/13  1   New Year's Day  January 1   2013    243 2   1   0.500000    19.90   0.20
2   93  1/1/13  1   New Year's Day  January 1   2013    192 22  1   0.045455    19.95   0.50
3   51  1/1/13  1   New Year's Day  January 1   2013    176 4   1   0.250000    27.00   0.27
4   28  1/1/13  1   New Year's Day  January 1   2013    444 4   1   0.250000    39.95   0.40

0 个答案:

没有答案