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


Python FigureCanvasGTK3Agg.blit方法代码示例

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


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

示例1: ChessAnalogWindow

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

#.........这里部分代码省略.........
        Gtk.main_quit()

    # Oy! 
    def warn_dialog(self, message):
        dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.WARNING,
                                   Gtk.ButtonsType.OK, "OHNOES!")
        dialog.format_secondary_text(message)
        response = dialog.run()

        # if response == Gtk.ResponseType.OK:
        #     print "WARN dialog closed by clicking OK button"

        dialog.destroy()

    def del_px_data(self, d_x):
        xpx_old, ypx_old = self.a.transData.transform((0, 0))
        xpx_new, ypx_new = self.a.transData.transform((d_x, 0))

        return(xpx_new - xpx_old)

    def update_plots(self):
        if (self.do_redraw):
            #print("redraw")
            self.a.clear()
            self.a.grid(True)
            self.canvas.draw()
            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.do_redraw = False


        self.a.set_xlim([self.x[-1] - self.fifo_size/SCAN_FREQ - 1, self.x[-1] + 1])
        # Restore the blank background
        self.canvas.restore_region(self.clean_bg)

        xarr = np.array(self.x)
        analog_arr = np.array(self.analog_data[0])
        analog_arr2 = np.array(self.analog_data[18])

        #lastx_ind = np.where(np.array(self.x) > self.lastx)
        lastx_ind = np.where(xarr > self.lastx)
        #lastx_ind = itertools.islice(self.lastx

        #print(lastx_ind[0])
        lastx_ind = lastx_ind[0]

        # Offset in time
        x_offset = abs(xarr[-1] - self.lastx)

        # Find the equivalent offset in display pixels
        pixel_offset = self.del_px_data(x_offset)
        dx_pixel = np.floor(pixel_offset)


        # Compute and redraw saved background (moved over).
        x1, y1, x2, y2 = self.background.get_extents()
        self.canvas.restore_region(self.background,
                                   bbox = (x1 + dx_pixel, y1, x2, y2),
                                   xy = (x1 - dx_pixel, y1))

        
        
        # if (len(lastx_ind) > 0):
        #     lastx_ind = np.array(itertools.islice(self.x, lastx_ind[0], self.fifo_size))
        # else:
        #     lastx_ind = np.array(self.x)
        # #print(lastx_ind)

        self.my_line.set_xdata(xarr[lastx_ind])
        self.my_line.set_ydata(analog_arr[lastx_ind])
        self.a.draw_artist(self.my_line)
        #self.canvas.draw()
        self.my_line2.set_xdata(xarr[lastx_ind])
        self.my_line2.set_ydata(analog_arr2[lastx_ind])
        self.a.draw_artist(self.my_line2)

        
        self.background = self.canvas.copy_from_bbox(self.get_bg_bbox(self.a))

        # Draw the axes (and grids if applicable)
        self.a.draw_artist(self.a.xaxis)
        self.a.draw_artist(self.a.yaxis)
        
        self.canvas.blit(self.f.bbox)
        self.lastx = self.x[-1]

        #self.canvas.draw()
        return(True)

    # def init_blit_plot(self):
    #     l = self.line.set_data([], [])
    #     return(l)

    def win_resize(self, win):
        #print("RESIZE!")

        # Don't do this here, instead activate a "needs redraw" class
        # var that instructs update_plot to do a full redraw.

        self.do_redraw = True
开发者ID:cosmonaut,项目名称:chess_analog_daq,代码行数:104,代码来源:analog_daq.py


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