SHARE
TWEET

Python - pandas display histogram

furas Jun 25th, 2018 (edited) 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3.  
  4. df = pd.DataFrame([1,2,2,3,4,4,4,5])
  5.  
  6. p = df.hist()
  7. p[0][0].set_title("my histogram")
  8.  
  9. plt.savefig('output.png')
  10.  
  11. plt.show()
  12.  
  13. #####################################################
  14.  
  15. import pandas as pd
  16. import matplotlib.pyplot as plt
  17.  
  18. df = pd.DataFrame([1,2,2,3,4,4,4,5])
  19.  
  20. df.hist()
  21. plt.show()
  22.  
  23. df.boxplot()
  24. plt.show()
  25.  
  26. #####################################################
  27.  
  28. import pandas as pd
  29. import matplotlib.pyplot as plt
  30.  
  31. df = pd.DataFrame([1,2,2,3,4,4,4,5])
  32.  
  33. fig, ax = plt.subplots(2,2) # 1 row, 2 columns
  34.  
  35. df.hist(ax=ax[0][0])
  36. df.boxplot(ax=ax[0][1])
  37. df.plot(ax=ax[1][0])
  38. df.plot(ax=ax[1][1], kind='bar')
  39.  
  40. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top