I have the charts I want but they show up in a single column. I would like two or three columns. This is what I have so far:
teamlist = ['ATL', 'BAL', 'BOS', 'LAA', 'CHA', 'CHN', 'CIN', 'CLE', 'DET',
'HOU', 'KCR', 'LAD', 'MIN', 'MIL', 'MON', 'NYY', 'NYM', 'OAK',
'PHI', 'PIT', 'SDP', 'SEA', 'SFG', 'STL', 'TEX', 'TOR', 'COL',
'MIA', 'ARI', 'TBA', 'WAS']
for i in teamlist:
data = teamdf[teamdf['teamID'] == i]
fig, ax1 = plt.subplots(figsize=(5,3))
ax1 = data.groupby('yearID').attendance.sum().plot(kind='line',label=i)
ax1.set_yticks([0, 1000000, 2000000, 3000000, 4000000])
ax1.set_yticklabels(labels=['0', '1M', '2M', '3M', '4M'], fontsize=10, color='#414141')
ax1.set_xticks([1990, 1995, 2000, 2005, 2010, 2015, 2019])
ax1.set_xticklabels(labels=['1990', '1995', '2000', '2005', '2010','2015','2019'], fontsize=10, color='#414141')
mean = teamdf.groupby('yearID').attendance.mean().plot(kind='line',color='gray',label='League Avg.')
ax1.set(title=i + ' Attendance 1990-2019', ylabel='Tickets Sold', xlabel='Year')
ax1.legend(loc='best')
I tried changing the number of rows and columns in the plt.subplots line in the loop but it created multiple columns for every single chart, and that's not what I want. I think I might need to do something before the loop to get 3 columns of charts but not sure.