当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasGTK3Agg.draw方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg.draw方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Agg.draw方法的具体用法?Python FigureCanvasGTK3Agg.draw怎么用?Python FigureCanvasGTK3Agg.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg的用法示例。


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

示例1: Plot

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class Plot(Gtk.Frame):
    def __init__(self, sp, refs):
        Gtk.Frame.__init__(self)
        self.f = Figure()
        self.canvas = FigureCanvas(self.f)
        self.add(self.canvas)
        self.set_size_request(1024, 600)
        self.f.subplots_adjust(left=0.07, right=0.98, bottom=0.05, top=0.95,
                               hspace=0.2, wspace=0.2)
        # self.buffer = self.canvas.get_snapshot()

    def decorate(self, axis, title=None, ylab=None, legend=None):
        # font_prop = fm.FontProperties(fname='Humor-Sans-1.0.ttf', size=14)
        if title is not None:
            axis.set_title(title)  # , fontproperties=font_prop)
        if ylab is not None:
            axis.yaxis.set_label_text(ylab)  # , fontproperties=font_prop)
        if legend is not None:
            axis.legend(legend)  # , prop=font_prop)
        axis.xaxis.grid(color='k', linestyle='-', linewidth=0.2)
        axis.yaxis.grid(color='k', linestyle='-', linewidth=0.2)

    def update(self, sp, refs):
        title = [r'$\phi$', r'$\theta$', r'$\psi$']
        legend = ['Ref1', 'Ref2', 'Setpoint']
        for i in range(0, 3):
            axis = self.f.add_subplot(331 + i)
            axis.clear()
            for ref in refs:
                axis.plot(sp.time, pu.deg_of_rad(ref.euler[:, i]))
            axis.plot(sp.time, pu.deg_of_rad(sp.euler[:, i]))
            self.decorate(axis, title[i], *(('deg', legend) if i == 0 else (None, None)))

        title = [r'$p$', r'$q$', r'$r$']
        for i in range(0, 3):
            axis = self.f.add_subplot(334 + i)
            axis.clear()
            for ref in refs:
                axis.plot(sp.time, pu.deg_of_rad(ref.vel[:, i]))
            self.decorate(axis, title[i], 'deg/s' if i == 0 else None)

        title = [r'$\dot{p}$', r'$\dot{q}$', r'$\dot{r}$']
        for i in range(0, 3):
            axis = self.f.add_subplot(337 + i)
            axis.clear()
            for ref in refs:
                axis.plot(sp.time, pu.deg_of_rad(ref.accel[:, i]))
            self.decorate(axis, title[i], 'deg/s2' if i == 0 else None)

        self.canvas.draw()
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:52,代码来源:att_ref_gui.py

示例2: OdPredictorGui

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class OdPredictorGui(Gtk.HBox):

    def __init__(self):
        super().__init__()
        self.controls = ControlPanel()
        self.controls.connect('new-params', self.on_new_params)

        self.fig = Figure(facecolor='#e9e9e9')
        self.axes = self.fig.add_subplot(1, 1, 1)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.set_size_request(300, 300)

        self.pack_start(self.controls, False, False, 0)
        self.pack_start(self.canvas, True, True, 0)

        self.on_new_params()

    def on_new_params(self, *args):
        predictor = self.controls.get_params()
        predictor.plot_time_estimate(self.axes)
        self.fig.tight_layout(pad=1.0)
        self.canvas.draw()
开发者ID:kalekundert,项目名称:wetlab_protocols,代码行数:24,代码来源:predict_od.py

示例3: Window

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]

#.........这里部分代码省略.........
    def update_plot(self, x=None, y=None):

        if not self.freeze_plot:

            if x is not None and y is not None:
                f = x
                z = y
            else:
                f = self.get_frequency()
                z = self.get_impedance(f)

            re = np.real(z)
            im = np.imag(z)
            r = 20.*np.log10(abs((z - 50.)/(z + 50.)))

            self.line_r.set_data(f/1e9, r)
            self.line_20.set_data(f/1e9, r)

            self.line_re.set_data(f/1e9, re)
            self.line_50.set_data([f[0]/1e9, f[-1.]/1e9], [-50., -50.])

            self.line_im.set_data(f/1e9, im)
            self.line_0.set_data([f[0]/1e9, f[-1.]/1e9], [0., 0.])

            self.line_abs.set_data(f/1e9, abs(z))
            self.line_00.set_data([f[0]/1e9, f[-1.]/1e9], [0., 0.])

            for ax in (self.ax1, self.ax2, self.ax3, self.ax4):

                ax.relim()
                ax.autoscale_view()

            self.line_20.set_data([f[0]/1e9, f[-1.]/1e9], [20., 20.])
            self.canvas.draw()

        if self.builder.get_object('checkbutton2').get_active():

            self.parameters = {'I_c' : self.builder.get_object('spinbuttonI_c').get_value()*1e-6,
                               'phi_dc' : self.builder.get_object('spinbuttonphi_dc').get_value(),
                               'phi_ac' : self.builder.get_object('spinbuttonphi_p').get_value(),
                               'phi_s' : self.builder.get_object('spinbuttonphi_s').get_value(),
                               'theta_p' : self.builder.get_object('spinbuttontheta_p').get_value(),
                               'C' : self.builder.get_object('spinbuttonC').get_value()*1e-12,
                               'L_s' : self.builder.get_object('spinbuttonL_s').get_value()*1e-12,
                               'f_p' : self.builder.get_object('spinbuttonf_p').get_value()*1e9,
                               'Z_l' : self.builder.get_object('spinbuttonz_l').get_value(),
                               'l' : self.builder.get_object('spinbuttonl').get_value()*1e-2,
                               'g_m' : self.builder.get_object('spinbuttong_m').get_value(),
                               'C_l' : 1.66e-10,
                               'L_l' : 4.21e-7,
                               'L_b' : self.builder.get_object('spinbuttonL_b').get_value()*1e-9}
        else:

            self.parameters = {'I_c' : self.builder.get_object('spinbuttonI_c').get_value()*1e-6,
                               'phi_dc' : self.builder.get_object('spinbuttonphi_dc').get_value(),
                               'phi_ac' : self.builder.get_object('spinbuttonphi_p').get_value(),
                               'phi_s' : self.builder.get_object('spinbuttonphi_s').get_value(),
                               'theta_p' : self.builder.get_object('spinbuttontheta_p').get_value(),
                               'C' : self.builder.get_object('spinbuttonC').get_value()*1e-12,
                               'L_s' : self.builder.get_object('spinbuttonL_s').get_value()*1e-12,
                               'f_p' : self.builder.get_object('spinbuttonf_p').get_value()*1e9}


        self.builder.get_object('entry1').set_text(str(self.parameters))

开发者ID:edumur,项目名称:paramp,代码行数:68,代码来源:gui.py

示例4: CampaignGraph

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class CampaignGraph(object):
	title = 'Unknown'
	_graph_id = None
	table_subscriptions = []
	def __init__(self, config, parent, size_request=None):
		self.config = config
		self.parent = parent
		self.figure, ax = pyplot.subplots()
		self.axes = self.figure.get_axes()
		self.canvas = FigureCanvas(self.figure)
		self.manager = None
		if size_request:
			self.canvas.set_size_request(*size_request)
		self.canvas.mpl_connect('button_press_event', self.mpl_signal_canvas_button_pressed)
		self.canvas.show()
		self.navigation_toolbar = NavigationToolbar(self.canvas, self.parent)
		self.navigation_toolbar.hide()
		self.popup_menu = Gtk.Menu.new()

		menu_item = Gtk.MenuItem.new_with_label('Export')
		menu_item.connect('activate', self.signal_activate_popup_menu_export)
		self.popup_menu.append(menu_item)

		menu_item = Gtk.MenuItem.new_with_label('Refresh')
		menu_item.connect('activate', lambda action: self.refresh())
		self.popup_menu.append(menu_item)

		menu_item = Gtk.CheckMenuItem.new_with_label('Show Toolbar')
		menu_item.connect('toggled', self.signal_toggled_popup_menu_show_toolbar)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

	@classmethod
	def get_graph_id(klass):
		return klass._graph_id

	def make_window(self):
		if self.manager == None:
			self.manager = FigureManager(self.canvas, 0)
		window = self.manager.window
		window.set_transient_for(self.parent)
		window.set_title(self.title)
		return window

	def mpl_signal_canvas_button_pressed(self, event):
		if event.button != 3:
			return
		pos_func = lambda m, d: (event.x, event.y, True)
		self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time())
		return True

	def signal_activate_popup_menu_export(self, action):
		dialog = gui_utilities.UtilityFileChooser('Export Graph', self.parent)
		file_name = self.config['campaign_name'] + '.png'
		response = dialog.run_quick_save(file_name)
		dialog.destroy()
		if not response:
			return
		destination_file = response['target_filename']
		self.figure.savefig(destination_file, format='png')

	def signal_toggled_popup_menu_show_toolbar(self, widget):
		if widget.get_property('active'):
			self.navigation_toolbar.show()
		else:
			self.navigation_toolbar.hide()

	def load_graph(self):
		self.refresh()

	def refresh(self, info_cache=None):
		info_cache = (info_cache or {})
		if not self.parent.rpc:
			return info_cache
		for table in self.table_subscriptions:
			if not table in info_cache:
				info_cache[table] = list(self.parent.rpc.remote_table('campaign/' + table, self.config['campaign_id']))
		map(lambda ax: ax.clear(), self.axes)
		self._load_graph(info_cache)
		self.canvas.draw()
		return info_cache
开发者ID:BaldyBadgersRunningRoundMyBrain,项目名称:king-phisher,代码行数:83,代码来源:graphs.py

示例5: PopUpImage

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class PopUpImage(object):
	def __init__(self, xdata, ydata, xlabel, ylabel, title):
		self.popupwin=Gtk.Window()
		self.popupwin.set_size_request(600,550)
		self.popupwin.set_position(Gtk.WindowPosition.CENTER)
		self.popupwin.set_border_width(10)
		self.xdata = xdata
		self.ydata = ydata
		vbox = Gtk.VBox()
		self.fig=Figure(dpi=100)
		self.ax  = self.fig.add_subplot(111)
		self.canvas  = FigureCanvas(self.fig)
		self.main_figure_navBar = NavigationToolbar(self.canvas, self)
		self.cursor = Cursor(self.ax, color='k', linewidth=1, useblit=True)
		self.canvas.mpl_connect("button_press_event",self.on_press)
		self.ax.set_xlabel(xlabel, fontsize = 18)
		self.ax.set_ylabel(ylabel, fontsize = 18)
		self.ax.set_title(title, fontsize = 18)
		self.ax.plot(self.xdata, self.ydata, 'b-', lw=2)
		
		self.textes = []
		self.plots  = []
		vbox.pack_start(self.main_figure_navBar, False, False, 0)
		vbox.pack_start(self.canvas, True, True, 2)
		self.popupwin.add(vbox)
		self.popupwin.connect("destroy", self.dest)
		self.popupwin.show_all()
	
	def dest(self,widget):
		self.popupwin.destroy()
	
	def on_press(self, event):
		if event.inaxes == self.ax and event.button==3:
			self.clear_notes()
			xc = event.xdata
			#***** Find the closest x value *****
			residuel = self.xdata - xc
			residuel = N.abs(residuel)
			j = N.argmin(residuel)
			#y = self.ydata[i-1:i+1]
			#yc= y.max()
			#j = N.where(self.ydata == yc)
			#j = j[0][0]
			xc= self.xdata[j]
			x_fit = self.xdata[j-3:j+3]
			y_fit = self.ydata[j-3:j+3]
			fitted_param, fitted_data = fit(x_fit, y_fit, xc, True)
			x_fit = N.linspace(x_fit.min(), x_fit.max(), 200)
			y_fit = psdVoigt(fitted_param, x_fit)
			period = fitted_param['xc'].value
			std_err= fitted_param['xc'].stderr
			
			p = self.ax.plot(x_fit, y_fit,'r-')
			p2 = self.ax.axvline(period,color='green',lw=2)
			
			txt=self.ax.text(0.05, 0.9, 'Period = %.4f +- %.4f (nm)'%(period, std_err), transform = self.ax.transAxes, color='red')
			self.textes.append(txt)
			self.plots.append(p[0])
			self.plots.append(p2)
		elif event.inaxes == self.ax and event.button==2:
			dif = N.diff(self.ydata)
			dif = dif/dif.max()
			p3  = self.ax.plot(dif,'r-')
			self.plots.append(p3[0])
		self.canvas.draw()
	
	def clear_notes(self):
		if len(self.textes)>0:
			for t in self.textes:
				t.remove()
		if len(self.plots)>0:
			for p in self.plots:
				p.remove()
		self.textes = []
		self.plots  = []
开发者ID:Traecp,项目名称:DEVA,代码行数:77,代码来源:PopUpWindows.py

示例6: LockinGui

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]

#.........这里部分代码省略.........
        self.scan_store.clear()


    # ## ----------- END scan Listview connect functions


    # ##---------------- Stage Control Button Connect functions ----------

    def show_pos(self):
        pos = self.stage.last_pos()
        # print(pos)
        self.label_x.set_text("x: {0:+8.4f}".format(pos[0]))
        self.label_y.set_text("y: {0:+8.4f}".format(pos[1]))
        self.label_z.set_text("z: {0:+8.4f}".format(pos[2]))

    def on_xup_clicked(self, widget):
        self.stage.moverel(dx=self.settings.stepsize)
        self.show_pos()

    def on_xdown_clicked(self, widget):
        self.stage.moverel(dx=-self.settings.stepsize)
        self.show_pos()

    def on_yup_clicked(self, widget):
        self.stage.moverel(dy=self.settings.stepsize)
        self.show_pos()

    def on_ydown_clicked(self, widget):
        self.stage.moverel(dy=-self.settings.stepsize)
        self.show_pos()

    def on_zup_clicked(self, widget):
        self.stage.moverel(dz=self.settings.stepsize)
        self.show_pos()

    def on_zdown_clicked(self, widget):
        self.stage.moverel(dz=-self.settings.stepsize)
        self.show_pos()

    def on_stepup_clicked(self, widget):
        self.settings.stepsize *= 10
        if self.settings.stepsize > 10:
            self.settings.stepsize = 10.0
        self.label_stepsize.set_text(str(self.settings.stepsize))
        self.settings.save()

    def on_stepdown_clicked(self, widget):
        self.settings.stepsize /= 10
        if self.settings.stepsize < 0.001:
            self.settings.stepsize = 0.001
        self.label_stepsize.set_text(str(self.settings.stepsize))
        self.settings.save()

    def on_moverel_clicked(self, widget):
        self.moverel_dialog.rundialog()
        self.show_pos()

    def on_moveabs_clicked(self, widget):
        self.moveabs_dialog.rundialog()
        self.show_pos()


    # ##---------------- END Stage Control Button Connect functions ------

    def run(self):
        """	run main gtk thread """
        try:
            GLib.timeout_add(self._heartbeat, self._update_plot)
            GLib.timeout_add(self._heartbeat, self._pad_make_step)
            GLib.io_add_watch(self.spectrum.conn_for_main, GLib.IO_IN | GLib.IO_PRI, self.spectrum.callback,
                              args=(self.spectrum,))
            if self.pad is not None:
                GLib.io_add_watch(self.pad.receiver, GLib.IO_IN | GLib.IO_PRI, self._on_pad_change, args=(self,))
            Gtk.main()
        except KeyboardInterrupt:
            pass

    def _update_plot(self):
        spec = self.spectrum.get_spec(self.button_corronoff.get_active())
        self.lines[0].set_ydata(spec)
        self.lines[1].set_ydata(self.spectrum.smooth(spec))
        #self.ax.set_ylim(min(spec[262:921]), max(spec[262:921]))
        self.ax.autoscale_view(None, False, True)
        self.canvas.draw()
        self.show_pos()
        return True

    def save_data(self):
        prefix = self.prefix_dialog.rundialog()
        if prefix is not None:
            try:
                # os.path.exists(prefix)
                os.mkdir(self.savedir+prefix)
            except:
                print("Error creating directory ./" + prefix)
            path = self.savedir + prefix + '/'
            self.spectrum.save_data(path)
            self.status.set_text("Data saved")
        else:
            self.status.set_text("Could not save data")
开发者ID:sdickreuter,项目名称:lock-in-spectrum,代码行数:104,代码来源:main.py

示例7: wykres_1

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]

#.........这里部分代码省略.........
        plt.setp(self.c.xaxis.set_major_formatter(xfmt))
        #plt.setp(self.c.xaxis.get_majorticklabels(), rotation=30)
        plt.setp(self.a.xaxis.set_major_formatter(xfmt))
        # plt.setp(self.a.xaxis.get_majorticklabels(), rotation=30)
        plt.setp(self.b.xaxis.set_major_formatter(xfmt))
        #plt.setp(self.b.xaxis.set_major_locator(md.HourLocator()))
        plt.setp(self.a.xaxis.set_major_locator(MaxNLocator(4)))
        plt.setp(self.b.xaxis.set_major_locator(MaxNLocator(4)))
        plt.setp(self.c.xaxis.set_major_locator(MaxNLocator(4)))
        #self.c.relim()
#         relim()
        #self.c.autoscale_view()
        #plt.gcf()
        #plt.ion()
        # plt.setp(self.b.xaxis.get_majorticklabels(), rotation=30)
        
        #self.b.subplot_adjust(bottom = 0.5)
# Add canvas to vbox
        self.canvas = FigureCanvas(self.f)  # a Gtk.DrawingArea
        self.vbox.pack_start(self.canvas, True, True, 5)
       
# Create toolbar
        self.toolbar = NavigationToolbar(self.canvas,self)
        self.vbox.pack_start(self.toolbar, False, False, 5)
        
        self.add(self.vpaned)
        self.vpaned.add(self.box)
        self.vpaned.add(self.vbox)
        self.show_all()
        self.s = GObject.timeout_add(6000,self.wykres)
        #GObject.idle_add(self.wykres)
    def on_pomiar_clicked(self,button):
        print("Dziala")
        stop = ("7B49080000EA4A7D")
        stop_d = stop.decode("hex")
        print(stop_d)
        ser.close()
        ser.open()
        ser.flushInput()
        ser.flushOutput()
        ser.write(stop_d)
        GObject.source_remove(self.s)
        self.destroy()

    def wykres(self):
        i_1 = datetime.datetime.now()
        #i_strip = datetime.datetime.now().strftime("%y-%m-%d-%H-%M-%S")
            
        #print("Czas datetime" )
        #print(i_1)    
        x1 = [date2num(i_1)]    
        print("Czas teraz: ") 
        print(x1)   
        nowy_pomiar = pomiar()
        #print("Czas kiedys: " )
        print(self.x)
        amon_1 = nowy_pomiar.amoniak()
        tmp = nowy_pomiar.temperatura()
        wda = nowy_pomiar.woda()
        amoniak = ("Pomiar amoniaku: " + amon_1 + " \t " + "Woda: " + wda +
                    " \t " + "Temperatura celi: " + tmp )
        z = str(amoniak)
        self.set_title(z)
        self.a.plot_date(x1,amon_1,tz = None,
                                color='green', linestyle = '-',
                                marker='o', markerfacecolor='blue', 
                                markersize=3)
        self.b = self.f.add_subplot(312)
        self.b.plot_date(x1,wda, tz=None,
                                color='green', linestyle = ':',
                                marker='o', markerfacecolor='blue', 
                                markersize=3)
           
        
        self.b.grid(True)
       
        self.b.set_xlabel('Czas')
        self.b.set_ylabel('Woda [ppm]')
        self.c = self.f.add_subplot(313)
        
        self.c.plot_date(x1,tmp,tz=None,
                                color='green', linestyle = ':',
                                marker='o', markerfacecolor='blue', 
                                markersize=3 )
                                   
        self.c.grid(True)
        #self.a.set_xlim(-3,22)
        self.c.set_ylim(5,55)
        self.c.set_xlabel('Czas')
        self.c.set_ylabel(u'Temperatura [\u00B0C]')  
        self.a.set_xlim((i_1 - timedelta(minutes=8), i_1 + timedelta(seconds=15)) )   
        self.b.set_xlim((i_1 - timedelta(minutes=8), i_1 + timedelta(seconds=15)) )
        self.c.set_xlim((i_1 - timedelta(minutes=8), i_1 + timedelta(seconds=15)) ) 
        #self.a.xticks(x1,i_1,rotation=45)    
        # self.a.xaxis.set_minor_formatter(dates.DateFormatter('%d%a'))
        #self.a.setp(rotation=30)
        time.sleep(1)
        self.canvas.draw()   
        #self.show_all() 
        return True       
开发者ID:insted,项目名称:testowe_1,代码行数:104,代码来源:main.py

示例8: myInterface

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class myInterface():

    def __init__(self, port, baud):
        print("Welcome to the MakeMeFly interface :D\nEnjoy your trip!")

        self.port=port
        self.baud=baud
        self.s=Serial(self.port, self.baud, timeout=0.5)
        self.inhibited=False;

        self.dataLock=Lock()
        self.printDataLock=Lock()
        self.bufLock=Lock()
        self.serialLock=Lock()
        self.saveStuffLock=Lock()
        self.buf=[]

        self.builder=Gtk.Builder()
        self.builder.add_from_file('Plotter_IF.glade')
        self.builder.connect_signals(self)

        self.squareWave=[]
        self.outputUp=[]
        self.outputDown=[]
        self.sw=0
        self.co=0
        self.ou=0
        self.od=0
        self.gb=0
        self.gp=0
        self.ur=0
        self.dr=0
        self.bM=0
        self.bm=0
        self.l=[]

        self.gainBase=[]
        self.gainPos=[]
        self.upRate=[]
        self.downRate=[]
        self.BMax=0
        self.BMin=0
        self.level=[]

        self.nData=1000
        self.BData=deque(maxlen=1000)
        self.filteredValueData=deque(maxlen=1000)
        self.coilBData=deque(maxlen=1000)
        self.BData.append(0)
        self.filteredValueData.append(0)
        self.coilBData.append(0)
        self.XData=[0.0004*x for x in range(0,1000)]

        self.window=self.builder.get_object("mainWindow")
        self.builder.get_object("sqWaveImage").set_from_stock("gtk-no", Gtk.IconSize.BUTTON)

        #Start of Matplotlib specific code
        ##########################################################################
        self.figure = Figure(figsize=(8,6), dpi=71)
        self.axisB = self.figure.add_subplot(311)
        self.axisB.set_xlabel('Time (ticks)')
        self.axisB.set_ylabel('Measured magnetic field')

        self.axisBC = self.figure.add_subplot(313)
        self.axisBC.set_xlabel('Time (ticks)')
        self.axisBC.set_ylabel('Emulated magnetic field')

        self.axisFV = self.figure.add_subplot(312)
        self.axisFV.set_xlabel('Time (ticks)')
        self.axisFV.set_ylabel('Filtered magnetic field')

        self.plotCanvas = PlotCanvas(self.figure)  # a Gtk.DrawingArea
        self.plotCanvas.set_size_request(500,600)
        a=[0]
        self.plotB=self.axisB.plot(a)[0]
        self.plotBC=self.axisBC.plot(a)[0]
        self.plotFV=self.axisFV.plot(a)[0]
        self.plotCanvas.draw()

        self.builder.get_object("plotGrid").attach(self.plotCanvas, 0,2,1,1)
        self.window.show_all()
        self.window.connect("destroy", Gtk.main_quit)

        self.newBytes=Condition()
        self.recvThread=Thread(target=self.recvBytes)
        self.recvThread.start()
        self.consumeDataThread=Thread(target=self.consumeData)
        self.consumeDataThread.start()

    def getNext(self, requested):
        while(len(self.buf)<requested):
            self.newBytes.acquire()
            self.newBytes.wait()
            self.newBytes.release()
        self.bufLock.acquire()
        values=self.buf[:requested]
        self.buf=self.buf[requested:]
        self.bufLock.release()
        return values

#.........这里部分代码省略.........
开发者ID:conte91,项目名称:MakeMeFly,代码行数:103,代码来源:makemefly_if.py

示例9: ChessAnalogWindow

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]

#.........这里部分代码省略.........
        self.f = Figure(figsize=(8,6), dpi=100)
        self.a = self.f.add_subplot(111)
        
        #self.line, = self.a.plot([], [], marker = 'x')
        #self.line, = self.a.plot([], [])
        #self.plt = self.a.plot([0, 1], [0, 3], marker = 'x')
        self.a.xaxis.set_animated(True)
        self.a.yaxis.set_animated(True)

        #self.a.set_xlim([0,5])
        self.a.set_xlim([self.fifo_size/SCAN_FREQ, 0])
        
        self.a.set_ylim([0,70000])
        
        self.a.grid(True)
        #self.a.set_xscale('log')
        #self.a.set_xlim((10.0, 30000.0))
        #self.a.set_ylim((-90.0, 3.0))
        self.a.set_xlabel("Time")
        self.a.set_ylabel("Voltage")

        self.lastx = 0
        self.my_line, = self.a.plot([], [], animated = True)
        self.my_line2, = self.a.plot([], [], animated = True)
        
        self.canvas = FigureCanvas(self.f)

        # Clean background
        self.clean_bg = self.canvas.copy_from_bbox(self.f.bbox)
        self.background = self.canvas.copy_from_bbox(self.get_bg_bbox(self.a))

        self.old_size = self.a.bbox.width, self.a.bbox.height

        self.canvas.draw()

        self.do_redraw = False

        #self.plot_timer = self.canvas.new_timer(interval = 42)

        # self.anim = ma.FuncAnimation(self.f, 
        #                              self.update_plots, 
        #                              event_source = self.plot_timer, 
        #                              init_func = self.init_blit_plot, 
        #                              repeat = False,
        #                              blit = True)

        #print(dir(self.anim))
        #self.anim._stop()
        #self.plot_timer.stop()
        self.master_hbox.pack_start(self.canvas, True, True, 0)
        #self.plot_timer.stop()

        self.connect("check-resize", self.win_resize)

    def acquire_cb(self, state):
        #print("acq callback")
        #print(state)
        if (self.action_acq.get_active()):
            # This is commented because it seems that comedi_cancel()
            # clears stale data in the fd and card?
            #data = os.read(self.fd, BUF_SIZE)
            #print("LEN DATA: %d" % len(data))

            # Start comedi command
            ret = c.comedi_command(self.dev, self.cmd)
            if (ret != 0):
开发者ID:cosmonaut,项目名称:chess_analog_daq,代码行数:70,代码来源:analog_daq.py

示例10: MainWindow

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw [as 别名]
class MainWindow(object):
    """Clase manejadora de la ventana principal.

    """
    def __init__(self):

        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(LANG_DOM)
        self.builder.add_from_file(UI_FILE)
        self.builder.connect_signals(self)
        self.win=self.builder.get_object('window1')
        self.graf_box=self.builder.get_object('graf_box')
        self.statusbar = self.builder.get_object('statusbar')
        self.statusbar.push(1,_('Last access: '))
        self.ui_label={}
        for label in labels:
            self.ui_label[label]=self.builder.get_object(label)

        fig = Figure()
        self.plot1 = fig.add_subplot(111)
        self.plot2 = fig.add_subplot(212)
        self.plot3 = fig.add_subplot(313)
        self.plot3.set_position([0.055,0.06,0.93,0.24])
        self.plot2.set_position([0.055,0.38,0.93,0.24])
        self.plot1.set_position([0.055,0.69,0.93,0.24])
        self.canvas = FigureCanvas(fig)
        self.graf_box.pack_start(self.canvas,True,True,0)

        self.win.show_all()
        if self.get_params():
            self.update_ui()
            GObject.timeout_add_seconds(180,self.update_ui)

    def get_params(self):
        #Obtener parametros de programa
        params=DataStore.ParamStore(APP_DIR,PARAM_FILE)
        self.dir_data=params.get('paths','dir_data')
        if self.dir_data==None:
            dialog = Gtk.FileChooserDialog(_("Select pywws data folder:"), self.win,
                     Gtk.FileChooserAction.SELECT_FOLDER,
                    (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,Gtk.STOCK_OK, Gtk.ResponseType.OK))
            response = dialog.run()
            if response == Gtk.ResponseType.OK:
                self.dir_data = dialog.get_filename()
                params.set('paths','dir_data',self.dir_data)
                params.flush()
            else:
                self.dir_data=''
            dialog.destroy()
        if not os.path.exists(self.dir_data):
            dialog = Gtk.MessageDialog(self.win,0, Gtk.MessageType.ERROR,Gtk.ButtonsType.CANCEL,
                     _("pywws data folder does not exist."))
            dialog.run()
            dialog.destroy()
            return False
        return True

    def update_ui(self):
        self.statusbar.pop(1)
        pywws_data=get_pywws_data(self.dir_data)
        if pywws_data==None:
            self.statusbar.push(1,_('Error accessing pywws data.'))
            return True
        idx=pywws_data['a']['idx'].replace(tzinfo=TimeZone.utc).astimezone(TimeZone.Local)
        self.statusbar.push(1,_('Last access: ')+idx.strftime('%c').decode('utf-8'))
        for label in labels:
            tipo_k,pywws_k,strfmt=_parse_label(label)
            self.ui_label[label].set_label(strfmt.format(pywws_data[tipo_k][pywws_k]))
        #plotting
        val=[],[],[],[],[],[],[]
        for d in pywws_data['g']:
            val[0].append(d['idx'])
            val[1].append(d['temp_out'])
            val[2].append(d['temp_in'])
            val[3].append(d['hum_out'])
            val[4].append(d['hum_in'])
        for d in pywws_data['h']:
            val[5].append(d['idx'])
            val[6].append(d['rain'])
        self.plot1.clear()
        self.plot2.clear()
        self.plot3.clear()
        self.plot1.plot(val[0],val[1],label=_('Outdoor Temp.'))
        self.plot1.plot(val[0],val[2],label=_('Indoor Temp.'))
        self.plot2.plot(val[0],val[3],label=_('Outdoor Hum.'),color='red')
        self.plot2.plot(val[0],val[4],label=_('Indoor Hum.'),color='magenta')
        self.plot3.plot(val[5],val[6],label=_('Rain'))
        self.plot1.set_title(_('Last 24 hours.'),fontsize=10)
        self.plot1.set_ylabel(_('ᴼC'),fontsize=10)
        self.plot2.set_ylabel(_('%'),fontsize=10)
        self.plot3.set_ylabel(_('mm'),fontsize=10)
        for plot in (self.plot1,self.plot2,self.plot3):
            plot.tick_params(labelsize=9)
            plot.xaxis.set_major_formatter(dates.DateFormatter('%H:%M',TimeZone.Local))
            plot.xaxis.set_major_locator(dates.HourLocator())
            plot.grid(True)
            plot.legend(loc='best',prop={'size':10})
        self.canvas.draw()
        return True

#.........这里部分代码省略.........
开发者ID:sersope,项目名称:wstation,代码行数:103,代码来源:wstation.py


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