fig = plt.figure(figsize=(12,12))
for i in range(5):
ax = fig.add_subplot(5,1,i+1)
ax.plot(unrate[i*12:(i+1)*12]['DATE'],unrate[i*12:(i+1)*12]['VALUE'])
How do I find out the handles for the 5 Axes objects created in this loop? Say that at a later stage, I want to modify one of them.
I tried fig.axes which provided following o/p. It didn’t give me usable handles.
[<matplotlib.axes._subplots.AxesSubplot object at 0x7fd4abc2b160>, <matplotlib.axes._subplots.AxesSubplot object at 0x7fd4abc7e2e8>, <matplotlib.axes._subplots.AxesSubplot object at 0x7fd4abba4b70>, <matplotlib.axes._subplots.AxesSubplot object at 0x7fd4abb63b70>, <matplotlib.axes._subplots.AxesSubplot object at 0x7fd4a9af0668>]
Thanks much Rucha. This helps. I used following two ways to set titles to one or all plots. Also, your way helps me to refer to a particular axes.
For All Titles
for i in range(5):
ax = fig.add_subplot(5,1,i+1, title='plot'+str(i))
ax.plot(unrate[i*12:(i+1)*12]['DATE'],unrate[i*12:(i+1)*12]['VALUE'])
Rucha’s trick: This answers my question. fig.axes[3].set_title("4th year")
There would always be some tweaking to be done. While I am new to analytics, I assume that prior to presenting an analysis there may be a need to say adjust ticks or font or title. Hence we would need to access the axes.