<quote author="Tony Yu-3">
A while back, I wrote some functions to calculate a good set of parameters for 
subplots_adjust (see attached; examples in if-main block at bottom). I've been 
using these functions pretty regularly, and it works pretty well for my 
purposes.

The function has to draw the figure a couple of times to calculate correct 
spacing. When redrawing the figure (e.g. when you resize the window), you'd 
have to re-call the function, which would redraw the figure a couple of times 
before drawing the final figure. That's all to say: this is a fairly slow 
function. If you don't have subplots (like in your example), you can call 
"layout.tight_borders()" (instead of "layout.tight()"), which only requires a 
single redraw.

When I originally posted this to the developers list, the functions didn't work 
with the GtkAgg backend. As far as I know, this hasn't changed. It should work 
fine for Qt4Agg, macosx, and TkAgg backends.
</quote>

Hi Tony,

I copied your layout.py.
Then run the following python script:
------------------------------------------------------
import matplotlib.pyplot as plt
import layout
import random

fontsizes = [8, 16, 24, 32]
def example_plot(ax):
     ax.plot([1, 2])
     ax.set_xlabel('x-label', fontsize=random.choice(fontsizes))
     ax.set_ylabel('y-label', fontsize=random.choice(fontsizes))
     ax.set_title('Title', fontsize=random.choice(fontsizes))

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
example_plot(ax4)

def on_resize(event):
     print( 'on_resize()' )
     layout.tight()

def on_close(event):
     print( 'on_close()' )
     fig.canvas.mpl_disconnect( rsiz_id )
     print rsiz_id

layout.tight()

if False:
#if True:
     rsiz_id = fig.canvas.mpl_connect('resize_event', on_resize)
     print rsiz_id
     fig.canvas.mpl_connect('close_event', on_close)

plt.show()
------------------------------------------------------

Without the resize event it works as expected.
With the resize event (as you suggested),
it only adjusts the borders of the four axes to the outside of the figure.
But between the axes there is no space at all.

Do I miss something?

Thanks a lot

Kurt
-- 
Kurt Mueller

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to