def add_background_image(fig, im, set_ratios=None):
 if (im is None):
  return None
 if (set_ratios is not None):
  for ax in fig.axes:
   ax.set_aspect(set_ratios)
 ax_im = fig.add_axes([0, 0, 1, 1], label='background')
 ax_im.imshow(im, aspect='auto')
 ax_im.set_zorder((-1))
 return ax_im

def add_background_image ( fig , im , set_ratios = None ) : if ( im is None ) : return None if ( set_ratios is not None ) : for ax in fig . axes : ax . set_aspect ( set_ratios ) ax_im = fig . add_axes ( [ 0 , 0 , 1 , 1 ] , label = 'background' ) ax_im . imshow ( im , aspect = 'auto' ) ax_im . set_zorder ( ( - 1 ) ) return ax_im
add a background image to a plot .