图例显示列名而不是标签名

时间:2020-07-08 07:19:17

标签: python matplotlib legend

我有以下代码显示第一个图的列名,而不是标签名。任何有关如何解决此问题的指导都欢迎。

sales_pred = results2.get_prediction(start=pd.to_datetime('2011-10-28'), dynamic=False)

pred_ci = sales_pred.conf_int()

ax = pivot_sales['2010':].plot(label='Actual Sales')
sales_pred.predicted_mean.plot(ax=ax, label='Sales Prediction', alpha=.7, figsize=(14, 4))

ax.fill_between(pred_ci.index,
                pred_ci.iloc[:, 0],
                pred_ci.iloc[:, 1], color='k', alpha=.2)

ax.set_xlabel('Date')
ax.set_ylabel('Weekly Sales')
plt.legend()
plt.show()

图例应显示实际销售额,而不是Weekly_Sales

enter image description here

0 个答案:

没有答案
相关问题