• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python widgets.RadioButtons类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.widgets.RadioButtons的典型用法代码示例。如果您正苦于以下问题:Python RadioButtons类的具体用法?Python RadioButtons怎么用?Python RadioButtons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RadioButtons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _create_controls

    def _create_controls(self):
        self._freq_ax = plt.axes([0.2, 0.19, 0.2, 0.03])
        self._freq_slider = Slider(self._freq_ax,
                                   'Frequency',
                                   0,
                                   self.samplerate / 2.0,
                                   valinit = self.frequency)
        self._freq_slider.on_changed(self.set_signal_frequency)

        self._ampl_ax = plt.axes([0.2, 0.1, 0.2, 0.03])
        self._ampl_slider = Slider(self._ampl_ax,
                                   'Amplitude',
                                   -100,
                                   0,
                                   valinit = dcv.lin2db(self.amplitude))
        self._ampl_slider.on_changed(self.set_signal_amplitude)

        self._signaltype_ax = plt.axes([0.5, 0.05, 0.15, 0.20])
        self._signaltype_radio = RadioButtons(self._signaltype_ax,
                                              ('Sine', 'Square', 'Sawtooth',
                                               'Triangle', 'Noise', 'Constant'))
        self._signaltype_radio.on_clicked(self.set_signal_type)

        self._windowtype_ax = plt.axes([0.7, 0.05, 0.15, 0.20])
        self._windowtype_radio = RadioButtons(self._windowtype_ax,
                                              ('Flat', 'Hanning', 'Hamming', 'Blackman'))
        self._windowtype_radio.on_clicked(self.set_window_type)
开发者ID:PengYingChuan,项目名称:yodel,代码行数:27,代码来源:fourier_analysis.py


示例2: slide_ddg

def slide_ddg(args):
    global new_df, radio, color_by, picked
    global scat, ax, sliders, sc_df, fig, cm, cbar
    sc_df = Rf.score_file2df(args['sc'], args['names'])
    args['logger'].log('score file has %i entries' % len(sc_df))
    if args['pc'] is not None:
        pc_df = get_rmsds_from_table(args['pc'])
        args['logger'].log('pc file had %i entries' % len(pc_df))
        a = sc_df.merge(pc_df, on='description')
        args['logger'].log('combined there are %i entries' % len(a))
        sc_df = a.copy()

    if args['percent'] != 100:
        threshold = np.percentile(sc_df[args['y']], args['percent'])
        sc_df = sc_df[ sc_df[args['y']] < threshold ]

    color_by = args['y']
    picked = False

    new_df = sc_df.copy()
    fig, ax = plt.subplots()
    plt.subplots_adjust(left=0.25, bottom=0.25)

    cm = plt.cm.get_cmap('RdYlBu')

    scat = ax.scatter(sc_df[args['x']].values, sc_df[args['y']].values, s=40, cmap=cm, c=sc_df[color_by], picker=True)
    cbar = plt.colorbar(scat)
    sliders = {}
    for i, term in enumerate(args['terms']):
        slider_ax = plt.axes([0.25, 0.01+i*0.035, 0.65, 0.03])
        sliders[term] = Slider(slider_ax, term, np.min(sc_df[term].values), np.max(sc_df[term].values), 0)
        sliders[term].on_changed(update)

    ax.set_xlim(np.min(new_df[args['x']].values)-1, np.max(new_df[args['x']].values)+1)
    ax.set_ylim(np.min(new_df[args['y']].values)-1, np.max(new_df[args['y']].values)+1)

    ax.set_xlabel(args['x'])
    ax.set_ylabel(args['y'])

    resetax = plt.axes([0.025, 0.7, 0.15, 0.15]) #[0.8, 0.025, 0.1, 0.04])
    button = Button(resetax, 'Reset', color='lightgoldenrodyellow', hovercolor='0.975')
    button.on_clicked(reset)

    printax = plt.axes([0.025, 0.3, 0.15, 0.15])
    printbutton = Button(printax, 'Print', color='green', hovercolor='red')
    printbutton.on_clicked(print_table)

    logax = plt.axes([0.025, 0.1, 0.15, 0.15])
    logbutton = Button(logax, 'log table', color='blue', hovercolor='red')
    logbutton.on_clicked(log_table)

    rax = plt.axes([0.025, 0.5, 0.15, 0.15], axisbg='white')
    radio = RadioButtons(rax, args['terms'], active=0)
    radio.on_clicked(colorfunc)

    # cbar = plt.colorbar(scat)
    pl = PointLabel(new_df, ax, fig, args['x'], args['y'], ['description', 'a_sasa', 'a_res_solv', 'a_pack', 'a_span_topo', 'a_ddg', 'fa_elec'], args['logger'])
    fig.canvas.mpl_connect('pick_event', pl.onpick)

    plt.show()
开发者ID:jonathaw,项目名称:general_scripts,代码行数:60,代码来源:scatter_sliders.py


示例3: setup_plot

def setup_plot():
	global rate_slider, delta_slider, fig, ax, l, radio
	fig, ax = plt.subplots()
	ax.grid('on')
	plt.subplots_adjust(left=0.25, bottom=0.25)
	moneyFmt = FuncFormatter(money)
	ax.yaxis.set_major_formatter(moneyFmt)

	s = calc_compounding( rate, periods, principal, contribution, delta,inflation)
	t = np.arange(2014, (2014+periods))
	l, = plt.plot(t,s, lw=2, color='red')
	plt.ylabel("Investment Loss (FV)")
	plt.axis([2014, (2014+periods), 0, principal])
	plt.axis('tight')

	axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
	axamp  = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)

	rate_slider = Slider(axfreq, 'Avg.Returns', 4, 8, valinit=rate)
	delta_slider = Slider(axamp, 'Delta', 0.1, 1, valinit=delta)
	resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
	button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
	rate_slider.on_changed(update)
	delta_slider.on_changed(update)
	button.on_clicked(reset)
	rax = plt.axes([0.015, 0.15, 0.15, 0.15], axisbg=axcolor)
	radio = RadioButtons(rax, ('0','3000', '6000', '9000'), active=0)
	radio.on_clicked(contribution_update)
	plt.show()
	return rate_slider,delta_slider,fig,ax,l,radio
开发者ID:bansalr,项目名称:fund_allocation,代码行数:30,代码来源:rate_of_return.py


示例4: WidgetsBasic

class WidgetsBasic(WidgetsSimple):
    def __init__(self, canvas=None, active_prop=None):
        super(WidgetsBasic, self).__init__(canvas, active_prop)

        self.colors_ifs = {}

    @property
    def prop_ifs(self):
        return self.active_prop

    def update_show_components(self, label):
        super(WidgetsBasic, self).update_show_components(label)
        if label == "hide ifs":
            if self.holder_actives[label]:
                self.prop_ifs.holder.set_linestyle(" ")
                self.prop_ifs.holder.set_visible(False)
                self.prop_ifs.set_visible_annotations(False)
                self.prop_ifs.topo_const.set_visible(False)
            else:
                self.prop_ifs.holder.set_linestyle(" ")
                self.prop_ifs.holder.set_visible(True)
                self.prop_ifs.set_visible_annotations(True)
                self.prop_ifs.topo_const.set_visible(True)

    # here is updated the active prop_ifs
    def recreate_widgets(self, idx_active, props, active_prop):
        super(WidgetsBasic, self).recreate_widgets_(active_prop)
        self._recreate_active_ifs_radiobutton(idx_active, props)

    def _recreate_active_ifs_radiobutton(self, idx_active, props):
        self.props = props
        axcolor = "lightgoldenrodyellow"
        if hasattr(self, "rax_activeifs"):
            self.rax_activeifs.cla()
        self.rax_activeifs = plt.axes(
            [0.2 + self.button_length__ + 0.01, 0.05, self.button_length__, self.button_height__], axisbg=axcolor
        )
        activecolor = self.active_prop.get_color()
        self.w_rad_active_ifs = RadioButtons(
            self.rax_activeifs, sorted(self.colors_ifs.keys()), active=idx_active, activecolor=activecolor
        )

        self.w_rad_active_ifs.on_clicked(self.colorfunc)
        return self.w_rad_active_ifs

    def colorfunc(self, label):
        idx = int(label)
        self.active_prop = self.props[idx]
        self.w_rad_active_ifs.activecolor = self.prop_ifs.get_color()
        self._recreate_radius_slider()
        self._recreate_show_lines_check_button()
        self._recreate_alpha_slider()
        self._recreate_textsize_slider()

        if self.canvas is None:
            self.canvas.draw()
开发者ID:jubi-ifs,项目名称:ifs-lattice,代码行数:56,代码来源:widgets_basic.py


示例5: run_main

def run_main(A,B,C,dA,dB,dC):
    
    plt.close()
    plt.figure()

    int_writer()
    var_writer_uncert(A,B,C)
    run_SPCAT()
    data = cat_reader()
    t = []
    s = []
    
    for x in data:
        s.append(0.0)
        s.append(str(10**float(x[1]))) 
        s.append(0.0)
        t.append(float(x[0])-0.0001)
        t.append(x[0])
        t.append(float(x[0])+0.0001)
    
    ax = plt.subplot(111)
    plt.subplots_adjust(left=0.25, bottom=0.25)
    
    a0 = 5
    f0 = 3
    global l
    l, = plt.plot(t,s, lw=2, color='red')
    #plt.axis([0, 1, -10, 10])
    
    axcolor = 'lightgoldenrodyellow'
    axA = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
    axB  = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
    axC  = plt.axes([0.25, 0.05, 0.65, 0.03], axisbg=axcolor)
    global A_slider
    global B_slider
    global C_slider
    
    A_slider = Slider(axA, 'A', A-dA, A+dA, valinit=A)
    B_slider = Slider(axB, 'B', B-dB, B+dB, valinit=B)
    C_slider = Slider(axC, 'C', C-dC, C+dC, valinit=C)
    A_slider.on_changed(update)
    B_slider.on_changed(update)
    C_slider.on_changed(update)
    global button
    global radio
    resetax = plt.axes([0.1, 0.025, 0.1, 0.04])
    button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
    button.on_clicked(reset)
    rax = plt.axes([0.025, 0.5, 0.15, 0.15], axisbg=axcolor)
    radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
    radio.on_clicked(colorfunc)
    plt.show()
开发者ID:jldmv,项目名称:bband_scripts,代码行数:52,代码来源:fitting_GUI_B_v2.py


示例6: _create_plot_controls

    def _create_plot_controls(self):
        self._dbrax = plt.axes([0.12, 0.05, 0.10, 0.10])
        self._dbradio = RadioButtons(self._dbrax, ('Amplitude', 'Phase'))
        self._dbradio.on_clicked(self.set_plot_style)

        self._rax = plt.axes([0.25, 0.03, 0.15, 0.20])
        self._radio = RadioButtons(self._rax, ('Low Pass', 'High Pass'))
        self._radio.on_clicked(self.set_biquad_type)

        self._sfax = plt.axes([0.6, 0.19, 0.2, 0.03])
        self._fcslider = Slider(self._sfax, 'Cut-off frequency', 0, self._bq_fs/2, valinit = self._bq_fc)

        self._fcslider.on_changed(self.set_biquad_frequency_cutoff)
开发者ID:PengYingChuan,项目名称:yodel,代码行数:13,代码来源:single_pole_filter_design.py


示例7: _GUI_display

    def _GUI_display(self,redshift_est,ztest,corr_val,wave,flux_sc):
        '''Display the spectrum and reference lines.'''
        self.fig = plt.figure(figsize=(10, 8)) 
        gs = gridspec.GridSpec(2, 1, height_ratios=[2, 1])
        ax2 = plt.subplot(gs[0])
        ax = plt.subplot(gs[1])
        plt.subplots_adjust(right=0.8)

        ax.plot(ztest,corr_val,'b')
        ax.axvline(redshift_est,color='k',ls='--')
        ax.fill_between(self.ztest,np.zeros(self.ztest.size),self.corr_prior,facecolor='grey',alpha=0.6)
        ax.set_xlabel('Redshift')
        ax.set_ylabel('Correlation')

        self.pspec, = ax2.plot(wave,flux_sc)
        ax2.axvline(3725.0*(1+redshift_est),ls='--',alpha=0.7,c='blue')
        ax2.axvline(3968.5*(1+redshift_est),ls='--',alpha=0.7,c='red')
        ax2.axvline(3933.7*(1+redshift_est),ls='--',alpha=0.7,c='red')
        ax2.axvline(4102.9*(1+redshift_est),ls='--',alpha=0.7,c='orange')
        ax2.axvline(4304.0*(1+redshift_est),ls='--',alpha=0.7,c='orange')
        ax2.axvline(4862.0*(1+redshift_est),ls='--',alpha=0.7,c='orange')
        ax2.axvline(4959.0*(1+redshift_est),ls='--',alpha=0.7,c='blue')
        ax2.axvline(5007.0*(1+redshift_est),ls='--',alpha=0.7,c='blue')
        ax2.axvline(5175.0*(1+redshift_est),ls='--',alpha=0.7,c='orange')
        if self.first_pass:
            self.line_est = Estimateline(self.pspec,ax2,self.uline_n)
        rax = plt.axes([0.85, 0.5, 0.1, 0.2])
        if self.qualityval == 0:
            radio = RadioButtons(rax, ('Unclear', 'Clear'))
        else:
            radio = RadioButtons(rax, ('Unclear', 'Clear'),active=1)
        def qualfunc(label):
            if label == 'Clear':
                self.qualityval = 1
            else:
                self.qualityval = 0
        radio.on_clicked(qualfunc)
        closeax = plt.axes([0.83, 0.3, 0.15, 0.1])
        button = Button(closeax, 'Accept & Close', hovercolor='0.975')
        def closeplot(event):
            plt.close()
        button.on_clicked(closeplot)
        ax2.set_xlim(self.lower_w,self.upper_w)
        ax2.set_xlabel('Wavelength (A)')
        ax2.set_ylabel('Counts')
        if not self.first_pass:
            self.spectra2 = DragSpectra(self.pspec,flux_sc,ax2,self.fig)
            self.fig.canvas.mpl_connect('motion_notify_event',self.spectra2.on_motion)
            self.fig.canvas.mpl_connect('button_press_event',self.spectra2.on_press)
            self.fig.canvas.mpl_connect('button_release_event',self.spectra2.on_release)
        plt.show()
开发者ID:giffordw,项目名称:OSMOSreduce,代码行数:51,代码来源:redshift_estimate.py


示例8: _create_plot_controls

    def _create_plot_controls(self):
        self._dbrax = plt.axes([0.12, 0.05, 0.15, 0.15])
        self._dbradio = RadioButtons(self._dbrax, ('Amplitude', 'Phase'))
        self._dbradio.on_clicked(self.set_plot_style)

        self._rax = plt.axes([0.30, 0.03, 0.15, 0.20])
        self._radio = RadioButtons(self._rax, ('feedback', 'feedforward', 'allpass'))
        self._radio.on_clicked(self.set_comb_type)

        self._sfax = plt.axes([0.6, 0.19, 0.2, 0.03])
        self._dlyslider = Slider(self._sfax, 'delay (ms)', 0, (self._size/2.0) * 1000.0 / self._fs, valinit = self._delay)
        self._dlyslider.on_changed(self.set_comb_delay)

        self._sfax = plt.axes([0.6, 0.10, 0.2, 0.03])
        self._gainslider = Slider(self._sfax, 'gain', -1, 1, valinit = self._gain)
        self._gainslider.on_changed(self.set_comb_gain)
开发者ID:PengYingChuan,项目名称:yodel,代码行数:16,代码来源:comb_filter_design.py


示例9: ReadFluxLC

    def ReadFluxLC(self,fluxLC):


        self.fluxes =  fluxLC.fluxes

        self.errors =  array(fluxLC.fluxErrors)
        self.tBins = fluxLC.tBins

        self.models = fluxLC.modelNames


        self.flcFlag =True


        axcolor = 'lightgoldenrodyellow'


 #       self.radioFig = plt.figure(2)
#
        ax = plt.axes([.01, 0.7, 0.2, 0.32], axisbg=axcolor)

        self.data = self.fluxes['total']

        if self.radio:
            del self.radio
            self.radioAx.cla()


        self.radio = RadioButtons(self.radioAx,tuple(self.fluxes.keys()))
        self.radio.on_clicked(self.Selector)
        
        self.PlotData()
开发者ID:JohannesBuchner,项目名称:spectralTools,代码行数:32,代码来源:pulseFit.py


示例10: __init__

  def __init__(self, image, low, high):
    self.image_name = image
    self.low = low
    self.high = high
    self.filter = None
    self.output = None
    self.filter_type = None
    self.padRows = None
    self.padCols = None

    original_input = cv2.imread(image,0)
    rows, cols = original_input.shape
    if(rows < cols):
      original_input = cv2.transpose(original_input)
      self.transposed = True
    else:
      self.transposed = False
      
    rows, cols = original_input.shape
    optimalRows = cv2.getOptimalDFTSize(rows)
    optimalCols = cv2.getOptimalDFTSize(cols)
    self.padRows = optimalRows - rows
    self.padCols = optimalCols - cols
    self.input = np.zeros((optimalRows,optimalCols))
    self.input[:rows,:cols] = original_input
    
    self.dftshift = get_dft_shift(self.input)

    plt.subplots_adjust(left=0, bottom=0.05, right=1, top=1, wspace=0, hspace=0)

    plt.subplot(131)
    plt.axis('off')
    plt.title('original image')
    plt.imshow(self.input, cmap = 'gray',interpolation='nearest')

    
    self.axslow = plt.axes([0.05, 0.01, 0.5, 0.02])
    self.slow = Slider(self.axslow, 'low', 0.01, 1, valinit=self.low)
    self.slow.on_changed(self.updateLow)

    self.axhigh = plt.axes([0.05, 0.03, 0.5, 0.02])
    self.shigh = Slider(self.axhigh, 'high', 0.01, 1, valinit=self.high)
    self.shigh.on_changed(self.updateHigh)

    self.slow.slidermax=self.shigh
    self.shigh.slidermin=self.slow


    self.axfilter = plt.axes([0.62, 0.01, 0.15, 0.04])
    self.rfilter = RadioButtons(self.axfilter, ('Gaussian Filter', 'Ideal Filter'))
    self.rfilter.on_clicked(self.updateFilterType)
    self.filter_type = self.rfilter.value_selected
    
    self.axprocess = plt.axes([0.8, 0.01, 0.08, 0.04])
    self.bprocess = Button(self.axprocess, 'Process')
    self.bprocess.on_clicked(self.process)

    self.axsave = plt.axes([0.88, 0.01, 0.08, 0.04])
    self.bsave = Button(self.axsave, 'Save')
    self.bsave.on_clicked(self.save)
开发者ID:huyuji,项目名称:garden,代码行数:60,代码来源:filter.py


示例11: LoadEFlux

    def LoadEFlux(self,fileName):

        flux  = pickle.load(open(fileName))
        
        self.fluxes = flux['energy fluxes']
        self.fluxErrors = flux['errors']
        self.tBins = flux['tBins']
        
        axcolor = 'lightgoldenrodyellow'


 #       self.radioFig = plt.figure(2)

        if self.radio:
            #del self.radio
            self.radioAx.cla()
#
        self.radioAx = plt.axes([.01, 0.7, 0.2, 0.32], axisbg=axcolor)

        self.data = self.fluxes['total']
        self.errors = self.fluxErrors['total']

        self.radio = RadioButtons(self.radioAx,tuple(self.fluxes.keys()))
        self.radio.on_clicked(self.Selector)
        
        self.PlotData()
开发者ID:JohannesBuchner,项目名称:spectralTools,代码行数:26,代码来源:pulseFit.py


示例12: __init__

  def __init__(self,image=None,imginfo={},verbosity=0,cmap=None,**kwargs):
    """
    image  ... (opt) 2D Array 
    imginfo... (opt) dictionary with parameters of the image
    verbosity. (opt) quiet (0), verbose (3), debug (4)
    futher options are passed to the imshow method of matplotlib
    """
    self.kwargs = kwargs;
    self.verbosity=verbosity;

    # open new figure and draw image
    self.fig  = plt.figure();
    self.axis = self.fig.add_subplot(111); 
    self.fig.subplots_adjust(right=0.85);
    self.AxesImage=None;
      
    # add Switches and Buttons
    axStyle = self.fig.add_axes([0.85, 0.1, 0.12, 0.12]);
    self.rbStyle = RadioButtons(axStyle,["linear","log","contour"]);
    self.rbStyle.on_clicked(self.set_style);
    self.currentstyle = "linear";
    axLine = self.fig.add_axes([0.85, 0.3, 0.12, 0.05]);    
    self.bLine = Button(axLine,'Line Profile');
    self.bLine.on_clicked(self._toggle_line_profile);
    self.LineProfile=None;
    self.bLine.color_activated='red';

    # key pressed
    self.fig.canvas.mpl_connect('key_press_event', self._key_press_callback)
   
    # draw image if given
    self.set_cmap(cmap);
    if image is not None: 
      self.set_image(image,imginfo);
开发者ID:rhambach,项目名称:TEMareels,代码行数:34,代码来源:wq_stack.py


示例13: slider_radio

def slider_radio():
    def update(val):
        amp = samp.val
        freq = sfreq.val
        l.set_ydata(amp*np.sin(2*np.pi*freq*t))
        fig.canvas.draw_idle()

    def reset(event):
        sfreq.reset()
        samp.reset()

    def colorfunc(label):
        l.set_color(label)
        fig.canvas.draw_idle()

    fig = figure()
    ax = fig.subplots()
    fig.subplots_adjust(left=0.25, bottom=0.25)
    t = np.arange(0.0, 1.0, 0.001)
    a0 = 5
    f0 = 3
    s = a0*np.sin(2*np.pi*f0*t)
    l, = ax.plot(t, s, lw=2, color='red')
    ax.axis([0, 1, -10, 10])
# %% plot axes
    axcolor = 'lightgoldenrodyellow'
    axfreq = fig.add_axes([0.25, 0.1, 0.65, 0.03], facecolor=axcolor)
    axamp = fig.add_axes([0.25, 0.15, 0.65, 0.03], facecolor=axcolor)
# %% freq slide
    sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0)
    samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0)
    sfreq.on_changed(update)
    samp.on_changed(update)
# %% reset button
    resetax = fig.add_axes([0.8, 0.025, 0.1, 0.04])
    button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')

    button.on_clicked(reset)
# %% color buttons
    rax = fig.add_axes([0.025, 0.5, 0.15, 0.15], facecolor=axcolor)
    radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
    radio.on_clicked(colorfunc)
# %% scoping
    axw = [axfreq, axamp, sfreq, samp, button, radio]  # place to hold all the axesWidgets to keep in scope

    return axw  # MUST return ax or GUI will be non-responsive!
开发者ID:scienceopen,项目名称:python-matlab-examples,代码行数:46,代码来源:widgets_slider_radio.py


示例14: plot_mapqs

def plot_mapqs(folder):
    """Plots the Distribution of MAPQ Scores for the Inversion Regions in the respective species
       folder : input folder to look for the files
    """
    
    mapqs_counts = defaultdict(list)
    mapqs_labels = defaultdict(list)

    strain_matcher = re.compile('(.*) \(.*\)')  ## regex to get strain name from radio button click
 
    ## Parse the information from the mapq count files and store the information in a dictionary of lists 
    for mapq_file in glob.glob(folder+"*.count.txt"):
        strain = mapq_file.split("/")[-1].split(".")[0]
        TEMP_HANDLE = open(mapq_file,'r')
        for line in TEMP_HANDLE:
            line = line.strip('\n')
            mapqs_counts[strain].append(int(line.split(' ')[0]))
            mapqs_labels[strain].append(line.split(' ')[1])
    
    fig, ax = plt.subplots()
    indexes = np.arange(len(mapqs_counts[S]))
    rects = plt.bar(indexes,mapqs_counts[S],0.5)
    ax.set_xticks(indexes+1*0.2)
    ax.set_xticklabels(mapqs_labels[S],rotation=30)

    rax1 = plt.axes([0.92, 0.1, 0.08, 0.8])
    radio1 = RadioButtons(rax1, ('MC (Sand)','CL (Sand)','CM (Sand)','CN (Sand)','TI (Sand)','DC (Sand)','MS (Sand)','CV (Sand)','PN (Rock)','AC (Rock)','LF (Rock)','MP (Rock)','MZ (Rock)'), active=0)
    
    def update1(strain):
        match = re.match(strain_matcher,strain)
        strain = match.group(1)
        #indexes = np.arange(len(mapqs_counts[S]))
        for rect,h in zip(rects,mapqs_counts[strain]):
            rect.set_height(h)
        ax.set_xticks(indexes+1*0.2)
        ax.set_xticklabels(mapqs_labels[strain],rotation=30)
        ax.relim()
        ax.autoscale()
        fig.canvas.draw_idle()
        #global S 
        #print S
        #S = strain

    radio1.on_clicked(update1)
    plt.show()
开发者ID:rpadmanabhan,项目名称:cichlid_inversions,代码行数:45,代码来源:create_plot.py


示例15: _init_radio

 def _init_radio(self):
     """
     Add radio buttons to the radio ax for color scale.
     self._make_radio_axes() needs to have been called.
     """
     self.radio = RadioButtons(
         self.radio_ax,
         labels=['log', 'linear'],
         active=1)
开发者ID:arq5x,项目名称:scurgen,代码行数:9,代码来源:plotting.py


示例16: Slider

def Slider():
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.widgets import Slider, Button, RadioButtons
    
    fig, ax = plt.subplots()
    plt.subplots_adjust(left=0.25, bottom=0.25)
    t = np.arange(0.0, 1.0, 0.001)
    a0 = 5
    f0 = 3
    s = a0*np.sin(2*np.pi*f0*t)
    l, = plt.plot(t,s, lw=2, color='red')
    plt.axis([0, 1, -10, 10])
    
    axcolor = 'lightgoldenrodyellow'
    axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
    axamp  = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
    
    sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0)
    samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0)
    
    def update(val):
        amp = samp.val
        freq = sfreq.val
        l.set_ydata(amp*np.sin(2*np.pi*freq*t))
        fig.canvas.draw_idle()
    sfreq.on_changed(update)
    samp.on_changed(update)
    
    resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
    button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
    def reset(event):
        sfreq.reset()
        samp.reset()
    button.on_clicked(reset)
    
    rax = plt.axes([0.025, 0.5, 0.15, 0.15], axisbg=axcolor)
    radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
    def colorfunc(label):
        l.set_color(label)
        fig.canvas.draw_idle()
    radio.on_clicked(colorfunc)
    
    plt.show()
开发者ID:luwy007,项目名称:MatPlotLib,代码行数:44,代码来源:MatPlotLib.py


示例17: setup_canvas

    def setup_canvas(self):
        """Create the figure and the axes for the plot and buttons."""

        # Initialise the figure.
        self.currentFigure = plt.figure()
        self.axes = self.currentFigure.add_subplot(1, 1, 1)

        # Create the image.
        self.start_plotting(self.originalDataset)

        # Create the class radio button.
        classAxesLoc = plt.axes([0.05, 0.05, 0.07, 0.1 * round(len(self.classToColorMapping) / 3)], axisbg='0.85')
        classAxesLoc.set_title('Class Options')
        classRadio = RadioButtons(classAxesLoc, active=0, activecolor='black', labels=[i for i in sorted(self.classToColorMapping)])
        classRadio.on_clicked(self.on_class_change)

        # Create the reset button.
        resetAxesLoc = plt.axes([0.05, 0.44, 0.07, 0.075], axisbg='white')
        resetButton = Button(resetAxesLoc, 'Reset')
        resetButton.on_clicked(self.on_reset)

        # Create the recompute boundaries button.
        recomputeAxesLoc = plt.axes([0.05, 0.54, 0.07, 0.075], axisbg='white')
        recomputeButton = Button(recomputeAxesLoc, 'Recompute')
        recomputeButton.on_clicked(self.on_recompute)

        # Create the k choice button.
        kAxesLoc = plt.axes([0.05, 0.65, 0.07, 0.15], axisbg='0.85')
        kAxesLoc.set_title('K Options')
        kRadio = RadioButtons(kAxesLoc, active=0, activecolor='black', labels=[1, 3, 5, 7])
        kRadio.on_clicked(self.on_k_change)

        # Create the add/delete radio button.
        addDeleteAxesLoc = plt.axes([0.05, 0.85, 0.07, 0.1], axisbg='0.85')
        addDeleteAxesLoc.set_title('Add/Delete Points')
        addDeleteRadio = RadioButtons(addDeleteAxesLoc, active=1, activecolor='black', labels=['Add', 'Delete'])
        addDeleteRadio.on_clicked(self.on_delete_change)

        # Attach the mouse click event.
        cid = self.currentFigure.canvas.mpl_connect('button_press_event', self.on_click)

        # Display the figure maximised. These commands to maximise the figure are for the Qt4Agg backend. If a different backend is being used, then
        # the maximisation command will likely need to be changed.
        figManager = plt.get_current_fig_manager()
        figManager.window.showMaximized()
        plt.show()

        # Disconnect the mouse click event.
        self.currentFigure.canvas.mpl_disconnect(cid)
开发者ID:SimonCB765,项目名称:Graphtastic,代码行数:49,代码来源:interactiveboundarydemo.py


示例18: AnalyzeFrame

class AnalyzeFrame(object):
    """
    A slider representing a floating point range

    """
    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)
        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)

    def update(self, op):
        for ax in self.axes:
            self.fig.delaxes(ax)
        for c in self.cursors:
            del c
        if op == "scatter":
            print "scatter_analyze" 
            self.axes, self.cursors = scatter_analyze(self.fig, self.data)
        elif op == "summary":
            print "summary_analyze" 
            self.axes, self.cursors = summary_analyze(self.fig, self.data, self.nbar, 1)
        elif op == "summary2":
            print "summary2_analyze" 
            self.axes, self.cursors = summary_analyze(self.fig, self.data, self.nbar, 2)
        elif op == "entry":
            print "entry_analyze" 
            self.axes, self.cursors = entry_analyze(self.fig, self.data, self.nbar)
        elif op == "exit":
            print "exit_analyze" 
            self.axes, self.cursors = exit_analyze(self.fig, self.data, self.nbar)
        elif op == "simple":
            self.axes, self.cursors = simple_entry_analyze(self.fig, self.data, self.nbar)
        #elif op == "hm":
            #axes, cursors = follow_entry_analyze(fig, data)
            #print "hm" 
        self.fig.canvas.draw()
开发者ID:vodkabuaa,项目名称:QuantDigger,代码行数:44,代码来源:analyze.py


示例19: _add_xscale_selector

 def _add_xscale_selector(self):
     """
     Add a radio button to the figure for selecting which scaling the x-axes
     should use.
     """
     pos_shp = [CONTOLS_START_X, 0.8, CONTROLS_WIDTH, CONTROLS_HEIGHT]
     rax = self.figure.add_axes(pos_shp, axisbg=AXCOLOUR, title="X Scale")
     xscale_tuple = ("log", "linear")
     self.xscale_selector = RadioButtons(rax, xscale_tuple, active=xscale_tuple.index(self.xscale))
     self.xscale_selector.on_clicked(self._update_xscale)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:10,代码来源:mplh5_coherence_spectrum.py


示例20: _add_mode_selector

 def _add_mode_selector(self):
     """
     Add a radio button to the figure for selecting which mode of the model
     should be displayed.
     """
     pos_shp = [0.02, 0.07, 0.04, 0.1 + 0.002 * self.model.number_of_modes]
     rax = self.ipp_fig.add_axes(pos_shp, axisbg=AXCOLOUR, title="Mode")
     mode_tuple = tuple(range(self.model.number_of_modes))
     self.mode_selector = RadioButtons(rax, mode_tuple, active=0)
     self.mode_selector.on_clicked(self._update_mode)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:10,代码来源:phase_plane_interactive.py



注:本文中的matplotlib.widgets.RadioButtons类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python widgets.RectangleSelector类代码示例发布时间:2022-05-27
下一篇:
Python widgets.CheckButtons类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap