我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用matplotlib.widgets.RadioButtons()。
def _radio_click(self, label): """ Event handler for selecting which editing type to use. Connected on line 763 with on_click method for RadioButtons object. """ if label == 'No Edit': if self._edit_curve is not None: self._edit_curve.set_bbox({'facecolor':'white', 'edgecolor': 'white', 'alpha': 0}) elif label == 'Manual Edit': if self._edit_curve is not None: self._edit_curve.set_bbox({'facecolor':'khaki', 'edgecolor': 'khaki', 'alpha': 1}) elif label == 'Bulk Shift': if self._edit_curve is not None: self._edit_curve.set_bbox({'facecolor':'khaki', 'edgecolor': 'khaki', 'alpha': 1}) self.fig.canvas.draw()
def __init__(self, fname, n=10, intraday=False): """ """ self.fig = plt.figure(facecolor='white') self.fig.canvas.set_window_title(u'??') self.nbar = n self.cursors = [] self.data, = load_datas(n, intraday, fname) print self.data self.axes = [] self.rax = plt.axes([0, 0.5, 0.08, 0.15]) self.radio = RadioButtons(self.rax, ('scatter', 'summary', 'summary2', 'entry', 'exit', 'simple'), active=0) self.axes, self.cursors = scatter_analyze(self.fig, self.data) self.radio.on_clicked(self.update)