This example demonstrates making line plots using Pandas and Matplotlib.
# Python for Finance, 2nd ed., Hilpisch, Ives
# Chapter 8 - Financial Time Series
# Figure 8-1 Financial time series data as line plots
# Python 3
# https://stooq.com/db/h/
# https://matplotlib.org/3.1.0/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py
# https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/subplots_demo.html
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
data = pd.read_csv('data.csv', index_col=0, parse_dates=True)
# Create subplots
fig, axs = plt.subplots(12, 1, figsize=(16,24))
plt.subplots_adjust(top=1, bottom=0, hspace=0.5)
i = 0
while i < 12:
axs[i].plot(data.iloc[:,i])
axs[i].set(title=data.columns[i], ylabel='Closing Price')
if i==11:
axs[i].set(title=data.columns[i], xlabel='Date')
i = i + 1
plt.savefig('PFF_Ch8_8-1.png')