Chans

subplot

Jul 2nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import pandas as pd
  3.  
  4. file = '../stocks.csv'
  5.  
  6. # Convert RangeIndex to DateTimeIndex
  7. stock = pd.read_csv(file, parse_dates=['Date'], index_col=['Date'])
  8.  
  9. plt.subplot(2,1,1)
  10. plt.plot(stock.index, stock['AAPL'], color='red')
  11. plt.xlabel('Date')
  12. plt.ylabel('Stock price')
  13. plt.title('AAPL Stock price in 2000')
  14.  
  15. plt.subplot(2,1,2)
  16. plt.plot(stock.index, stock['MSFT'], color='blue')
  17. plt.title('MSFT Stock price in 2000')
  18. plt.xlabel('Date')
  19. plt.ylabel('Stock price')
  20.  
  21. plt.tight_layout()
  22. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment