Guest User

Untitled

a guest
Oct 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import pandas as pd
  3.  
  4. df = pd.DataFrame({"Apple" : [2,3,4,1], "Banana" : [4,2,1,2]})
  5.  
  6. ax = df.plot.barh()
  7. ax.legend()
  8.  
  9. plt.show()
  10.  
  11. h, l = ax.get_legend_handles_labels()
  12. ax.legend(h[::-1], l[::-1])
  13.  
  14. ax = df.plot.barh()
  15. ax.invert_yaxis()
  16.  
  17. import matplotlib.pyplot as plt
  18. import pandas as pd
  19.  
  20. df = pd.DataFrame({"Apple" : [2,3,4,1], "Banana" : [4,2,1,2]})
  21. df = df.reindex_axis(reversed(sorted(df.columns)), axis = 1)
  22. ax = df.plot.barh()
  23. ax.legend()
  24.  
  25. plt.show()
Add Comment
Please, Sign In to add comment