![](/img/trans.png)
[英]Change bar order and legend order in plot (matplotlib/pandas)
[英]bar plot does not respect order of the legend text in matplotlib
只是注意到图例文本与绘图栏的顺序不同。 我希望看到“香蕉”成为传说中的第一名。 是否可以纠正这种行为? 谢谢
我的代码是:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({"Apple" : [2,3,4,1], "Banana" : [4,2,1,2]})
ax = df.plot.barh()
ax.legend()
plt.show()
我的图:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.