Open rbaltrusch opened 1 week ago
Install pip install matplotlib ipywidgets
import matplotlib.pyplot as plt from ipywidgets import Button, VBox from IPython.display import display
fig, ax = plt.subplots() #figure and axis
x = [1, 2, 3, 4, 5] #some initial plot data y = [1, 4, 2, 3, 5] line, = ax.plot(x, y)
def clear_plot(b): ax.cla() # Clearing the current axis fig.canvas.draw() # Redraw the figure
clear_button = Button(description="Clear Plot") #Create a button and set the function to on click clear_button.on_click(clear_plot)
display(VBox([clear_button, fig.canvas])) #showing the button
Reference https://www.activestate.com/resources/quick-reads/how-to-clear-a-plot-in-python/
Hi @ShubhamKalsekar, thanks for your contribution. Can you integrate the code for this button into the existing gui and send a PR my way? Thanks :+1: Let me know if you need any help :)
PS: I would prefer not to add any extra dependencies to the project, I believe the current dependencies matplotlib and tkinter should suffice for this.
Add 'clear plot' button. Currently, the only way to clear plots of previous runs is to restart the GUI.