I have a list of data frames:
list_df = [df1, df2, df3, df4, df5, df6]
of which are are defined by fairly identical commands:
df6 = df_2016['Incident Type Description'].value_counts()[:20]
Where df1 = df_2011['Incident Type Description'].value_counts()[:20]
,
df2 = df_2012['Incident Type Description'].value_counts()[:20]
and so on to df6 = df_2016['Incident Type Description'].value_counts()[:20]
. df_2011, df_2012...df_2016
are named variables from csv files I uploaded.
What I wish to do is join all these to create a 2x3 subplot instead of having them individually displayed of which I had with the command: df_2016['Incident Type Description'].value_counts()[:20].plot(kind='barh', title='Top 20 crimes in Oakland in 2016')
I have tried a few approaches so far that I have found on stackoverflow [How can I plot separate Pandas DataFrames as subplots? and the matplotlib page, but these do not work and I don't know why (I'm a beginner in python):
axes= plt.subplots(2, 3)
list_df = [df1, df2, df3, df4, df5, df6]
columns = [f'Top 20 crimes in {x}' for x in range(2011, 2017)]
list_df.plot.barh(subplots=True, layout=(2, 3), figsize=(15,7))
So far ValueError
comes up as ValueError: Layout of 2x3 must be larger than required size 7
. Any ideas?