Something like this:
figPausedText = fig.text(...)
def my_save(fig, * args, **kwargs):
figPausedText.set_visible(False)
fig.savefig(*args, **kwargs)
figPausedText.set_visible(True)
If you want to get really clever, you can monkey patch your Figure object:
import types
figPausedText = fig.text(...)
# make sure we have a copy of the origanal savefig
old_save = matplotlib.figure.Figure.savefig
# our new function which well hide and then re-show your text
def my_save(fig, *args, **kwargs):
figPausedText.set_visible(False)
ret = old_save(fig, *args, **kwargs)
figPausedText.set_visible(True)
return ret
# monkey patch just this instantiation
fig.savefig = types.MethodType(my_save, fig)
or if you need this to work through the tool bar
import types
figPausedText = fig.text(...)
# make sure we have a copy of the origanal print_figure
old_print = fig.canvas.print_figure # this is a bound function
# if we want to do this right it is backend dependent
# our new function which well hide and then re-show your text
def my_save(canvas, *args, **kwargs):
figPausedText.set_visible(False)
ret = old_print(*args, **kwargs) # we saved the bound function, so don't need canvas
figPausedText.set_visible(True)
return ret
# monkey patch just this instantiation
fig.canvas.print_figure = types.MethodType(my_save, fig.canvas)