Reputation: 5591
I have a dataframe that looks like:
(Using ipython notebook..)
import pandas as pd
pd.options.display.mpl_style = 'default'
%matplotlib
import matplotlib.pyplot as plt
df = pd.DataFrame({'Average': {'April- 2014': 94.400000000000006,
'August- 2014': 94.400000000000006,
'December- 2014': 94.400000000000006,
'February- 2015': 94.400000000000006,
'January- 2015': 94.400000000000006,
'July- 2014': 94.400000000000006,
'June- 2014': 94.400000000000006,
'May- 2014': 94.400000000000006,
'November- 2014': 94.400000000000006,
'October- 2014': 94.400000000000006,
'September- 2014': 94.400000000000006},
'Number': {'April- 2014': 80,
'August- 2014': 86,
'December- 2014': 110,
'February- 2015': 11,
'January- 2015': 104,
'July- 2014': 90,
'June- 2014': 83,
'May- 2014': 108,
'November- 2014': 118,
'October- 2014': 127,
'September- 2014': 107}})
Per the documentation listed here you should be able to do this:
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(15, 8))
df['Number'].plot(ax=axes[0, 0])
However, it results in: IndexError: too many indices for array
What's the easiest way to plot subplots?
Upvotes: 3
Views: 2584
Reputation: 104
I will copy Tom's answer from the comments here.
Check your
axes.shape
. It's(2,)
so you only need.plot(ax=axes[0])
. There's also thesubplots=True
argument toDataFrame.plot
It should work.
Upvotes: 6