matplotlib- 2个传说中的一个情节

时间:2018-05-18 11:50:03

标签: python matplotlib legend legend-properties

我有以下代码:

plt.subplot2grid(shape=(2,3),loc=(0,0))
df.Survived.value_counts(normalize=True).plot(kind="bar",alpha=0.6,color= ['b','r'])
plt.title("Bar Representation- Survived wrt Age")
plt.xlabel("Survived")
plt.ylabel("Percentage")
plt.show()

图表如下所示:

enter image description here

我只是想在条形图的右上角添加2个图例,Survived and Died。就像在这张图中一样:Graph

另外,我想让标签0和1垂直对齐。

0 个答案:

没有答案