[Matplotlib-users] NxM subplots, tight, suptitle
Heiland, Randy
heiland at iu.edu
Sun Dec 17 09:07:19 EST 2017
On Dec 17, 2017, at 3:43 AM, Johann Rohwer <jr at sun.ac.za<mailto:jr at sun.ac.za>> wrote:
On 16/12/17 23:54, Heiland, Randy wrote:
Any advice for wanting to do a grid of subplots, with fig.tight_layout(), and with "extra” space at the top for a suptitle? As this simple script demonstrates, there isn’t really any space left at the top after doing tight_layout:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12,4))
ax0, ax1 = axes.flatten()
fig.tight_layout()
plt.suptitle('This is a somewhat long figure title', y=0.99, fontsize=12)
plt.show()
You can adjust the space individually for left, top, right, and bottom, as well as horizontally and vertically between the subplots, with fig.subplots_adjust().
call signature::
subplots_adjust(left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None)
The parameter meanings (and suggested defaults) are::
left = 0.125 # the left side of the subplots of the figure
right = 0.9 # the right side of the subplots of the figure
bottom = 0.1 # the bottom of the subplots of the figure
top = 0.9 # the top of the subplots of the figure
wspace = 0.2 # the amount of width reserved for blank space between subplots
hspace = 0.2 # the amount of height reserved for white space between subplots
The actual defaults are controlled by the rc file
File: /usr/lib/python2.7/dist-packages/matplotlib/pyplot.py
Type: function
The integrity and confidentiality of this email is governed by these terms / Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende bepalings gereël. http://www.sun.ac.za/emaildisclaimer
_______________________________________________
Thanks very much, Johann. I’d actually played around with subplots_adjust previously and gave up. However, your email nudged me back to it and I do indeed have pretty good results now. And for the record, one would use this *instead* of the tight_layout, not in addition to it.
Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171217/522d7266/attachment-0001.html>
More information about the Matplotlib-users
mailing list