Huge space between title and plot matplotlib
<p>I've a issue with matplotlib that generates a plot(graph) very far from the title. My code is:</p>

<pre><code>df = pandas.read_csv(csvpath, delimiter=',', 
                     index_col=0, 
                     parse_dates=[0], dayfirst=True, 
                     names=['Date','test1'])

df.plot(subplots=True, marker='.',markersize=8, title ="test", fontsize = 10, color=['b','g','g'], figsize=(8, 22))

imagepath = 'capture.png'

plt.savefig(imagepath)
</code></pre>

<p>An example of the graph generated is:</p>

<p><a href="http://i.stack.imgur.com/ZBKEP.png" rel="nofollow"><img src="http://i.stack.imgur.com/ZBKEP.png" alt="enter image description here"></a></p>

<p>Any idea why this is happening? Thanks a lot.</p>

<p>You can adjust the title location by grabbing the <code>figure</code> object from one of the 3 <code>axis</code> objects that is returned in an array from <code>df.plot</code>.  Using <code>fig.tight_layout</code> removes extra whitespace, but a known problem is that is also sets the figure title within the top plot.  However, you can fix that using the last line below.</p>

<pre><code>ax = df.plot(subplots=True, marker='.', markersize=8, 
             title ="test", fontsize = 10, color=['b','g','g'], 
             figsize=(8, 22))[0] 
fig = ax.get_figure()
fig.tight_layout()
fig.subplots_adjust(top=0.95)
</code></pre>

python matplotlib