Dec-22-2020, 03:01 PM
I'm trying to plot five price subplots in a 2x3 grid:
import pandas as pd import matplotlib.pyplot as plt import datetime rawdate_start = '2007-01-01' #input('Please enter start date as YYYY-MM-DD: ') rawdate_end = '2019-01-01' #input('Please enter end date as YYYY-MM-DD: ') markets = ['ES', 'GC', 'CL', 'EC', 'US'] plt.figure(facecolor='lightgrey') subplot_count = 1 for market in markets: columnname_0 = market+'_Close' columnname_1 = market+'_Daily_Rtn' columnname_2 = market+'_Cum_Rtn' columnname_3 = market+'_Value' market = pd.read_csv(r'C:\Users\drkle\{}(daily).csv'.format(market), parse_dates=["Date"], index_col="Date") market_cut = market.drop(['Open','High','Low','Vol','OI'],axis=1) market_cut = market_cut[rawdate_start:rawdate_end] market_cut.columns = [columnname_0] plt.subplot(3,2,subplot_count) plt.plot(columnname_0) subplot_count += 1 plt.show()I thought matplotlib was supposed to recognize this as a datetime index (from Line 15) and print dates accordingly (from Lines 5, 6, 17) so they are legible. I'm getting five empty subplots with x-axis tick values from -0.05 to +0.05 (increments of 0.25). Why no dates? Thanks!