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


Python backend_gtkagg.FigureCanvasGTKAgg类代码示例

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


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

示例1: __init__

class Display:
    """ This class is responsible for rendering the graph in the upper portion
    of the window.  The data in the graph is taken from a Simulation object,
    which is accessed through the main Interface object. """

    # This is a color I chose to perfectly match the background of the rest of
    # the interface.  It might only work on my computer.
    # Malingo: Yes, it only works on your computer. It depends on what gtk
    # theme the user has chosen.
    background = "#edecea"

    def __init__(self, main):
        self.main = main

        pi = numpy.pi
        self.abscissa = numpy.arange(-pi - .25, pi + 0.25, 0.01)

        self.curve = None
        self.canvas = None

    def setup(self, layout):
        """ This method creates the graph that is displayed on the top half of
        the user interface.  Currently, the axes are completely hard-coded in
        this method and cannot be changed on-the-fly. """

        figure = Figure(facecolor=Display.background)
        axes = figure.add_subplot(111)

        # In order to create a line object, a dummy line needs to be plotted.
        # This line will get replaced before the GUI is shown to the user.
        pi = numpy.pi
        x = y = self.abscissa

        self.curve = axes.plot(x, y)[0]
        self.canvas = FigureCanvasGTKAgg(figure)

        # The tick labels are formatted using LaTeX.  This makes it possible
        # to use symbols like pi.
        axes.set_xticks((-pi, 0, pi))
        axes.set_xticklabels((r"-\pi", "0", r"\pi"))
        axes.set_xlim(-pi - 0.25, pi + 0.25)

        axes.set_yticks((0, 1))
        axes.set_yticklabels(("0", "1"))
        axes.set_ylim((-0.1, 1.1))

        layout.pack_start(self.canvas)

    def update(self):
        """ This method updates the graph using the new ordinate values
        returned by the simulation. """

        main = self.main
        simulation = main.simulation
        ordinate = simulation.plot(self.abscissa)

        self.curve.set_ydata(ordinate)
        self.canvas.draw()
开发者ID:Malingo,项目名称:DoubleSlit,代码行数:58,代码来源:interface.py

示例2: drawMonitorTest

    def drawMonitorTest(self):
        try:
            self.builder.get_object("tmcspace").remove(self.canvastmc)
            self.axistmc.clear()
        except:
            pass
        #Add cropping
        self.axistmc.imshow(self.tmonimage, cmap=cm.gray) #set scale to 0,255 somehow

        #Maybe this needn't be redefined for every draw - only need draw() but not drawn often anyway
        self.canvastmc=FigureCanvasGTKAgg(self.figuretmc)

        self.canvastmc.draw()
        self.canvastmc.show()
        self.builder.get_object("tmcspace").pack_start(self.canvastmc, True, True)


        for i in range(len(self.trlist)):
            for cont in self.contours:
                #if self.rlist[i]==cont.ritem:
                #TODO remove hidden parameters here
                if np.abs(self.trlist[i][0][0]-cont.ritem[0][0])<=4 and np.abs(self.trlist[i][0][1]-cont.ritem[0][1])<=4:
                    item=self.trlist[i]
                    r=Rectangle(item[0], item[1], item[2], fill=False, color="blue")
                    self.axistmc.add_patch(r)
                    #could add width, height check as well

        #Always draw saved contours in blue
        for ditem in self.contours:
            item=ditem.ritem
开发者ID:jamesmcm,项目名称:MLTest,代码行数:30,代码来源:gui.py

示例3: openCameraConfig

    def openCameraConfig(self):
        try:
            self.builder.get_object("ccimgbox").remove(self.canvascc)
        except:
            pass
        ret,img = self.cap.read() 
        try:
            img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
            #cv2.imshow("newtest",img)
        except:
            img=np.zeros((100,100))
        self.builder.get_object("resx").set_text(str(img.shape[1]))
        self.builder.get_object("resy").set_text(str(img.shape[0]))
        self.resolution=(img.shape[1], img.shape[0])

        if img.shape[1]<self.screensize[0] and img.shape[0]<self.screensize[1]:
            pass
        else:
            img=imresize(img, (img.shape[0]/2, img.shape[1]/2))
            

        self.axiscc.imshow(img, cmap=cm.gray) #set scale to 0,255 somehow
        self.canvascc=FigureCanvasGTKAgg(self.figurecc)
        self.canvascc.draw()
        self.canvascc.show()
        self.builder.get_object("ccimgbox").pack_start(self.canvascc, True, True)

        self.builder.get_object("cameraconfig").set_visible(1)
开发者ID:jamesmcm,项目名称:MLTest,代码行数:28,代码来源:gui.py

示例4: __init__

    def __init__(self, dpi=100, x_pixel_size=500, y_pixel_size=400):
        gtk.HBox.__init__(self)
        # If the class is being reinitialized, we need to remove the old plot
        [self.remove(child) for child in self.get_children()]
        self.vbox = gtk.VBox()
        self.pack_start(self.vbox)
        # this is bad with labels, I have to figure out why
        self.connect('size_allocate', self._full_update)

        self.fig = Figure(figsize=(float(x_pixel_size)/dpi,
                                   float(y_pixel_size)/dpi),
                          dpi=dpi)
        self.fig.set_facecolor('white')
        self.canvas = FigureCanvasGTKAgg(self.fig)
        self.ax = self.fig.add_subplot(111)
        self.vbox.pack_end(self.canvas)
        self.canvas.connect('button_press_event', self._on_mouse_click)

        self.first_update = True
        self.settings = {}
        self.n_lines = None
        #self.line_styles = None
        #self.line_colors = None
        self.lines = None
        self.saved_window_size = None
        self.background = None
        self.auto_x_scale = False
        self.auto_y_scale = False
开发者ID:BBelonder,项目名称:PyExpLabSys,代码行数:28,代码来源:LivePlotsCommon.py

示例5: setup

    def setup(self, layout):
        """ This method creates the graph that is displayed on the top half of
        the user interface.  Currently, the axes are completely hard-coded in
        this method and cannot be changed on-the-fly. """

        figure = Figure(facecolor=Display.background)
        axes = figure.add_subplot(111)

        # In order to create a line object, a dummy line needs to be plotted.
        # This line will get replaced before the GUI is shown to the user.
        pi = numpy.pi
        x = y = self.abscissa

        self.curve = axes.plot(x, y)[0]
        self.canvas = FigureCanvasGTKAgg(figure)

        # The tick labels are formatted using LaTeX.  This makes it possible
        # to use symbols like pi.
        axes.set_xticks((-pi, 0, pi))
        axes.set_xticklabels((r"-\pi", "0", r"\pi"))
        axes.set_xlim(-pi - 0.25, pi + 0.25)

        axes.set_yticks((0, 1))
        axes.set_yticklabels(("0", "1"))
        axes.set_ylim((-0.1, 1.1))

        layout.pack_start(self.canvas)
开发者ID:Malingo,项目名称:DoubleSlit,代码行数:27,代码来源:interface.py

示例6: recreate_canvas

 def recreate_canvas(self, fig):
     canvas = FigureCanvas(fig)
     canvas.set_size_request(450, 200)
     if self.canvas_frame.get_child():
         self.canvas_frame.remove(self.canvas_frame.get_child())
     self.canvas_frame.add(canvas)
     canvas.show()
开发者ID:schlamar,项目名称:sitforc,代码行数:7,代码来源:gui.py

示例7: __init__

    def __init__(self):
        print 'test'
        self.win = gtk.Window()
        #win.connect("destroy", lambda x: gtk.main_quit())
        self.win.connect("delete-event", self.hideinsteadofdelete)
        self.win.set_default_size(400,300)
        self.win.set_title("Embedding in GTK")

        f = Figure(figsize=(5,4), dpi=100)
        a = f.add_subplot(111)
        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)
        a.plot(t,s)

        sw = gtk.ScrolledWindow()
        self.win.add (sw)
        # A scrolled window border goes outside the scrollbars and viewport
        sw.set_border_width (10)
        # policy: ALWAYS, AUTOMATIC, NEVER
        sw.set_policy (hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                       vscrollbar_policy=gtk.POLICY_ALWAYS)

        canvas = FigureCanvas(f)  # a gtk.DrawingArea
        canvas.set_size_request(800,600)
        sw.add_with_viewport (canvas)

        self.win.show_all()
        gtk.main()
开发者ID:badbytes,项目名称:pymeg,代码行数:28,代码来源:gtkpylab.py

示例8: Plotter

class Plotter(gtk.VBox):
    def __init__(self, xlabel, ylabel, width=500, height=500, dpi=75):
        """
        :type xlabel: str
        :type ylabel: str
        :type width: int
        :type height: int
        :type dpi: int
        """
        gtk.VBox.__init__(self)
        figure = Figure(figsize=(width, height), dpi=dpi)
        self.axes = figure.add_subplot(111, xlabel=xlabel, ylabel=ylabel)
        """ :type: matplotlib.axes.Axes """
        self.axes.hold(False)
        self.canvas = FigureCanvas(figure)
        #self.canvas.mpl_connect('button_press_event', self.klick)
        nav = NavigationToolbar(self.canvas, self)
        self.pack_start(nav, False, False)
        self.pack_start(self.canvas)

    def leeren(self):
        self.axes.hold(False)

    def plot(self, x, y, **args):
        self.axes.plot(x, y, antialiased=True, **args)
        self.axes.hold(True)

    def draw(self):
        self.canvas.draw()

    """def klick(self, evt):
开发者ID:lustra,项目名称:SpeckView,代码行数:31,代码来源:Plotter.py

示例9: visualize

def visualize(*args, **kwargs):
    """
    Method that does all magic to to with GTK.

    All arguments passed to grapher.matplot.Graph
    """

    logger.debug('Spawning a GTK window')
    win = gtk.Window()
    win.connect('destroy', lambda x: gtk.main_quit())
    win.set_default_size(800,500)
    win.set_title('BounceItBaby visualizer')

    sw = gtk.ScrolledWindow()
    win.add(sw)
    # TODO: allow arrow/hjkl buttons to scroll
    sw.set_policy(hscrollbar_policy=gtk.POLICY_ALWAYS,
                  vscrollbar_policy=gtk.POLICY_AUTOMATIC)

    logger.debug('Building the Figure from data')
    figure = Graph(*args, **kwargs)
    canvas = FigureCanvas(figure)
    # If time scale is 20 times longer than number of actors, make it 20 times
    # wider than it is tall.
    canvas.set_size_request(int(400 / figure.axes[0].get_data_ratio()), 400)
    sw.add_with_viewport(canvas)

    logger.debug('Displaying GTK window!')
    win.show_all()
    gtk.main()
开发者ID:xim,项目名称:bounceitbaby,代码行数:30,代码来源:gtk_grapher.py

示例10: __init__

    def __init__(self,src,model,state):
        self.src = src
        self.model = model
        self.__state = state
        state.connect('selection-changed',self.update_spanner)
        state.connect('selection-removed',self.remove_spanner)
        xb = src.get_time_bounds()
        yb = src.get_data_bounds()
        figure = Figure(dpi=100)
        self.plot = figure.add_subplot(111,xbound=xb,ybound=yb,autoscale_on=False)
        self.plot.plot_date(src.get_time(True),src.get_data(True),'-')
        if state.selection is None:
            self.spanner = None
        else:
            vall,valr = state.selection
            self.spanner = self.plot.axvspan(vall,valr,alpha=0.5)
        self.ctx_spanners = dict()
        FigureCanvas.__init__(self,figure)
        self.mpl_connect('button_press_event',self.on_press)
        self.mpl_connect('button_release_event',self.on_release)
        self.mpl_connect('motion_notify_event',self.on_move)
        model.connect('annotation-added',self.notice_annotation)
        model.connect('annotation-removed',self.notice_annotation_removal)
        model.connect('annotation-changed',self.notice_annotation_change)

        for (id,color,boundl,boundr) in model.annotations():
            self.notice_annotation(model,id,color,boundl,boundr)
开发者ID:hguenther,项目名称:context-annotator,代码行数:27,代码来源:display.py

示例11: __init__

class HelloMatplotlib:
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_size_request(400, 400)
        self.window.set_border_width(10)

        f = Figure(figsize=(5,4), dpi=100)
        a = f.add_subplot(111)
        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)
        a.plot(t,s)

        self.canvas = FigureCanvas(f)
        self.canvas.show()
        self.window.add(self.canvas)
        self.window.show()

    def delete_event(self, widget, event, data=None):
        gtk.main_quit()

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def main(self):
        gtk.main()
开发者ID:adamchainz,项目名称:pynsist,代码行数:27,代码来源:hellomatplotlib.py

示例12: __init__

  def __init__(self, x, y, title="Graph", parent=None):
    gtk.Window.__init__(self)
    try:
      self.set_screen(parent.get_screen())
    except:
      self.connect('destroy', lambda *w: self.destroy())

    self.set_title(title)
    self.set_default_size(800, 600)
    self.set_border_width(2)
    self.set_position(gtk.WIN_POS_CENTER)

    box = gtk.VBox()
    self.add(box)

    fig = Fig(figsize=(5,4), dpi=100)
    ax = fig.add_subplot(111)
    ax.plot(x, y)

    canvas = FigCan(fig)
    canvas.mpl_connect('key_press_event', self.on_key_event)
    box.pack_start(canvas)

    toolbar = NavBar(canvas, self)
    box.pack_start(toolbar, False, False)

    self.show_all()

    del box, fig, ax, canvas, toolbar
开发者ID:moyeah,项目名称:wp,代码行数:29,代码来源:wp_graph.py

示例13: __init__

    def __init__(self):
        
        self._gladefile = "neuronview.glade"

        self._builder = gtk.Builder()
        self._builder.add_from_file(self._gladefile)
        self._builder.connect_signals(self)

        self._win = self._builder.get_object("mainwindow")
        self._win.resize(900, 700)

        box = self._builder.get_object("box5")
        self._stimulatordictview = DictView()
        self._builder.get_object("scrolledwindow2").add(self._stimulatordictview)

        box = self._builder.get_object("box4")
        self._neurondictview = DictView()
        self._builder.get_object("scrolledwindow3").add(self._neurondictview)

        self.populate_comboboxes()

        self._figure = Figure(figsize=(5,4), dpi=100)
        canvas = FigureCanvas(self._figure)
        canvas.set_size_request(200, 250)
        canvas.show()

        box = self._builder.get_object("box3")
        bg_style = box.get_style().bg[gtk.STATE_NORMAL]
        gtk_color = (bg_style.red_float, bg_style.green_float, bg_style.blue_float)
        self._figure.set_facecolor(gtk_color)
        box.pack_start(canvas)

        self._win.show()
        gtk.main()
开发者ID:JanneM,项目名称:nest-simulator,代码行数:34,代码来源:neuronview.py

示例14: __init__

    def __init__(self):
        # Minimal gtk initialization
        self.builder = gtk.Builder()
        self.builder.add_from_file("roi_image.glade")
        self.builder.connect_signals(self)

        # Create a matplotlib figure for the image        
        self.imageFigure = Figure(figsize=(5,4), dpi=100)
        self.imagePlot = self.imageFigure.add_subplot(111)

        # Place the matplotlib figures into a container
        self.imageCanvas = FigureCanvas(self.imageFigure)  # a gtk.DrawingArea
        self.builder.get_object('imageViewPort').add(self.imageCanvas)

        # Create a matplotlib figure for the plot       
        self.plotFigure = Figure(figsize=(5,4), dpi=100)
        self.plotPlot = self.plotFigure.add_subplot(111)

        # Place the matplotlib figures into a container
        self.plotCanvas = FigureCanvas(self.plotFigure)  # a gtk.DrawingArea
        self.builder.get_object('plotViewPort').add(self.plotCanvas)

        self.builder.get_object('lowIndexSlider').set_range(0,2047)
        self.builder.get_object('lowIndexSlider').set_value(0)
        
        self.builder.get_object('highIndexSlider').set_range(0,2047)
        self.builder.get_object('highIndexSlider').set_value(2047)

        self.mCurrentLowLimit = 0
        self.mCurrentHighLimit = 2047
开发者ID:H-Y-S,项目名称:FIMA,代码行数:30,代码来源:roi_image.py

示例15: __init__

	def __init__(self,t_from,t_to):
		self.figure = Figure(figsize=(10,2), dpi=80)
		self.t_from = t_from
		self.t_to = t_to
		self.t_diff = math.fabs(t_from - t_to)

		self.axis = None
	
		FigureCanvas.__init__(self,self.figure)
开发者ID:RTS2,项目名称:rts2-gtk,代码行数:9,代码来源:plot.py


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