I have the following code, which shows a graph with a slinding bar
from matplotlib.widgets import Slider import matplotlib.pyplot as plt from numpy i
Based on this you need to keep the sliders around globally.
Your example would only need to be slightly adjusted:
def myplot(): (... same code as above) return szoom keep_sliders = myplot()