def figure_nobar(*args, **kwargs):
 from matplotlib import rcParams, pyplot as plt
 old_val = rcParams['toolbar']
 try:
  rcParams['toolbar'] = 'none'
  fig = plt.figure(*args, **kwargs)
  cbs = list(fig.canvas.callbacks.callbacks['key_press_event'].keys())
  for key in cbs:
   fig.canvas.callbacks.disconnect(key)
 except Exception as ex:
  raise ex
 finally:
  rcParams['toolbar'] = old_val
 return fig

def figure_nobar ( * args , ** kwargs ) : from matplotlib import rcParams , pyplot as plt old_val = rcParams [ 'toolbar' ] try : rcParams [ 'toolbar' ] = 'none' fig = plt . figure ( * args , ** kwargs ) cbs = list ( fig . canvas . callbacks . callbacks [ 'key_press_event' ] . keys ( ) ) for key in cbs : fig . canvas . callbacks . disconnect ( key ) except Exception as ex : raise ex finally : rcParams [ 'toolbar' ] = old_val return fig
make matplotlib figure with no toolbar .