If the plots are embbed in a tkinter window, there can't be any figure define inside the function corresponding to the different parameters, otherwise it will raise performance issues, and probably undefined variables errors if the script has to remake each figure every time a parameters is changed. Instead, it is more interesting to update the existing figure.