SHARE
TWEET

Python - plot

furas Jun 27th, 2018 60 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. headers = 'Date', 'Close', 'Open', 'High', 'Low'
  5.  
  6. text = '''27/12/2012 4541,79 4560,12 4560,75 4534,55
  7. 28/12/2012 4561,98 4541,79 4561,99 4536,47
  8. 31/12/2012 4579,85 4559,31 4579,85 4558,51
  9. 02/01/2013 4621,99 4588,08 4621,99 4586,71
  10. 03/01/2013 4642,08 4643,92 4654,52 4621,81
  11. 04/01/2013 4654,33 4648,85 4677,97 4642,69
  12. 07/01/2013 4652,74 4651,63 4663,86 4632,11'''.replace(',', '.')
  13.  
  14. # --- create data ---
  15.  
  16. data = [line.split() for line in text.split('\n')]
  17.  
  18. df = pd.DataFrame(data, columns=headers)    
  19. df['Close'] = df['Close'].astype(float)
  20.  
  21. # --- plot ---
  22.  
  23. p = df['Close'].plot()
  24. #p.set_xlabel('Date')
  25. #p.set_ylabel('Close')
  26. p.set_xticklabels(df['Date'])
  27.  
  28. 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