I am trying to plot a panel of 3 plots using matplotlib and the subplots() method. I have a numpy array of the mean values for the data and a second array for the standard error for the mean values. I tried to create a plot but keep getting an IndexError: too many indices for array.
The numpy array looks like this:
mean_matrix
f1 f2 f3
8.3 4.1 12.9
8.5 4.3 11.2
std_matrix
f1 f2 f3
2.3 0.4 1.2
1.2 0.2 1.3
So here is my code. As you can see, I am trying to plot the mean and then use a fill for 1.96 times the standard error.
f, axarr = plt.subplots(nrows = 1, ncols=3)
axarr[0,0].plot(range(duration), mean_matrix['f1'], subplots=True)
axarr[0,0].fill_between(range(duration), mean_matrix['f1'] +
1.96*std_matrix['f1'], mean_matrix['f1'] -
1.96*std_matrix['f1'], alpha=0.5)
axarr[0,1].plot(range(duration), mean_matrix['f2'], subplots=True)
axarr[0,1].fill_between(range(duration), mean_matrix['f2'] +
1.96*std_matrix['f2'], mean_matrix['f2'] -
1.96*std_matrix['f2'], alpha=0.5 )
axarr[0,2].plot(range(duration), mean_matrix['f3'], subplots=True)
axarr[0,2].fill_between(range(duration), mean_matrix['f3'] +
1.96*std_matrix['f3'], mean_matrix['f3'] -
1.96*std_matrix['f3'], alpha=0.5 )
I get the error: IndexError: too many indices for array