I've a issue with matplotlib that generates a plot(graph) very far from the title. My code is:
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)
An example of the graph generated is:
Any idea why this is happening? Thanks a lot.
You can adjust the title location by grabbing the figure
object from one of the 3 axis
objects that is returned in an array from df.plot
. Using fig.tight_layout
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With