def tight_layout(pad=1.2, h_pad=None, w_pad=None, fig=None):
 import matplotlib.pyplot as plt
 fig = (plt.gcf() if (fig is None) else fig)
 fig.canvas.draw()
 try:
  fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad)
 except Exception:
  try:
   fig.set_tight_layout(dict(pad=pad, h_pad=h_pad, w_pad=w_pad))
  except Exception:
   warn('Matplotlib function "tight_layout" is not supported. Skipping subplot adjustment.')

def tight_layout ( pad = 1.2 , h_pad = None , w_pad = None , fig = None ) : import matplotlib . pyplot as plt fig = ( plt . gcf ( ) if ( fig is None ) else fig ) fig . canvas . draw ( ) try : fig . tight_layout ( pad = pad , h_pad = h_pad , w_pad = w_pad ) except Exception : try : fig . set_tight_layout ( dict ( pad = pad , h_pad = h_pad , w_pad = w_pad ) ) except Exception : warn ( 'Matplotlib function "tight_layout" is not supported. Skipping subplot adjustment.' )
automatically adjust subplot parameters to give specified padding .