我的数据框stats
有两列Old
和New
。我将它们绘制在两个独立的子图中,但我想重命名我的传说,但保留字幕。 plt.legend(labels= ['Stats'])
只重命名一个子图符号。非常感谢您的帮助。
stats.plot(kind='bar',
grid=False, subplots=True,
figsize=(20,10), fontsize=16,
color='#2E9240',
sharex=True, sharey=True)
plt.tick_params(
axis='x', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom='off', # ticks along the bottom edge are off
top='off', # ticks along the top edge are off
labelbottom='off') # labels along the bottom edge are off
plt.legend(labels= ['Stats'])
plt.show()
答案 0 :(得分:1)
DataFrame.plot返回每个子图的绘图轴或轴数组。使用轴来改变它们的图例。
axs = stats.plot(kind='bar',
grid=False, subplots=True,
figsize=(20,10), fontsize=16,
color='#2E9240',
sharex=True, sharey=True)
for axes in axs:
ax.legend(['Stats'])