Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- h, l = ax.get_legend_handles_labels()
- ax.legend(h[::-1], l[::-1])
- ax = df.plot.barh()
- ax.invert_yaxis()
- import matplotlib.pyplot as plt
- import pandas as pd
- df = pd.DataFrame({"Apple" : [2,3,4,1], "Banana" : [4,2,1,2]})
- df = df.reindex_axis(reversed(sorted(df.columns)), axis = 1)
- ax = df.plot.barh()
- ax.legend()
- plt.show()
Add Comment
Please, Sign In to add comment