I want to create something that can show (and hide with the same button) a line.
Here's what I have for the moment :
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
fig, ax = plt.subplots()
class Index(object):
ind = 0
def test(self, event):
self.plt.plot([0, 0], [1, 1])
plt.draw()
callback = Index()
axtest = plt.axes([0.81, 0.05, 0.1, 0.075])
btest = Button(axtest, 'Test')
btest.on_clicked(callback.test)
plt.show()
Can someone help me with this script ? I really can't figure out how to do this.