matplotlib: how do I easily fit the plot to the canvas
May be that is a simple question - but I tried to solve it several times - and just can't make it work. My problem is that - my plot is larger than the canvas:
Is there a way to make plot fit to the canvas - without changing the canvas size?
Here's the code that I use to make a plot (thanks to the Louis):
da = plt.figure()
l1 = da.add_subplot(111).plot(dummyZ, delta_a, "k-")
da.add_subplot(111).set_xlabel(r"$z/L$")
da.add_subplot(111).set_ylabel(r"$\delta a(z)$")
da.add_subpl开发者_如何学编程ot(111).grid(True)
da.savefig("da.png")
And here's the preambule:
import matplotlib.pyplot as plt
plt.rcParams['font.size']=18
Edit:
That's what I'm using now:
da = plt.figure()
l1 = da.add_subplot(111).plot(dummyZ, delta_a, "k-")
da.add_subplot(111).set_xlabel(r"$z/L$")
da.add_subplot(111).set_ylabel(r"$\delta a(z)$")
da.add_subplot(111).grid(True)
da.subplots_adjust(left=0.2, bottom=0.15) # !!!
da.savefig("da.png")
If I understand correctly the question, you want more room on the left to get the scale title ?
This is to be done with
fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
I had it with a simple
subplots_adjust(top=0.8)
to adjust the top of one of my draws.
Hope this could help.
精彩评论