There may be a more elegant way, but you can always monitor the status of each of these flags yourself, for example. in dict . The function that you specify with on_clicked() will receive the label of the active cell as the second argument, which you can then use to update the state accordingly:
import matplotlib.pyplot as plt from matplotlib.widgets import CheckButtons class Example: def onColor(self,label): self.cstates[label] = not self.cstates[label] print 'un'*(not self.cstates[label]) + 'checked %s' %label self.updateChart() def onMeasurement(self,label): self.mstates[label] = not self.mstates[label] print 'un'*(not self.mstates[label]) + 'checked %s' %label self.updateChart() def updateChart(self, event=None): """do something here using self.cstates and self.mstates?""" pass def __init__(self): colourax = plt.axes([0.5, 0.4, 0.09, 0.2]) measurementax = plt.axes([0.5, 0.6, 0.09, 0.2]) clabels, cvals = ('Red', 'Green', 'Blue'), (False,)*3 mlabels, mvals = ('1', '2', '3'), (False,)*3 self.cstates = dict(zip(clabels,cvals)) self.mstates = dict(zip(mlabels,mvals)) self.colours = CheckButtons(colourax, clabels, cvals) self.colours.on_clicked(self.onColor) self.measurements = CheckButtons(measurementax, mlabels, mvals) self.measurements.on_clicked(self.onMeasurement) def run(self): plt.show() ex = Example() ex.run()
Not the most beautiful, but it works!
ali_m source share