示例#1
0
    def __init__(self, m12, shot, trade, params, index, save_pos, stop_pos):
        self.index = index
        self.fig = plt.figure(index, figsize=(11, 6.1875))
        self.ax = [
            self.fig.add_subplot(3, 4, 1),
            self.fig.add_subplot(3, 4, 2),
            self.fig.add_subplot(3, 4, 3),
            self.fig.add_subplot(3, 4, 4),
            self.fig.add_subplot(3, 4, 5),
            self.fig.add_subplot(3, 4, 6),
            self.fig.add_subplot(3, 4, 7),
            self.fig.add_subplot(3, 4, 8),
            self.fig.add_subplot(3, 4, 9),
            self.fig.add_subplot(3, 4, 10),
            self.fig.add_subplot(3, 4, 11),
            self.fig.add_subplot(3, 4, 12)
        ]

        self.region = [par.Rect() for _ in range(12)]
        self.fig.tight_layout()
        self.params = params
        self.fig.canvas.set_window_title(params.inst)

        self.m12 = m12
        self.shot = shot
        self.trade = trade
        self.save_pos = save_pos
        self.stop_pos = stop_pos

        self.art = []
        for i in range(12):
            self.art.append(
                artist7.Artist7(m12, shot, self.ax[i], "art" + str(i), i))

        self.anim_interval = 10

        self.cur_pos = self.params.data_len
        self.show_future = True

        if self.index == 0:
            self.fig.canvas.mpl_connect('key_press_event', self.press)
            self.fig.canvas.mpl_connect('close_event', self.handle_close)
            self.fig.canvas.mpl_connect('resize_event', self.on_resize)
            self.fig.canvas.mpl_connect('button_press_event', self.onclick)

        # self.fig.canvas.mpl_connect('button_press_event', self.onClick)
        self.event_source = self.fig.canvas.new_timer()
        self.event_source.interval = self.anim_interval

        animation.TimedAnimation.__init__(self,
                                          self.fig,
                                          interval=self.anim_interval,
                                          event_source=self.event_source,
                                          blit=True)
示例#2
0
    def __init__(self, m12, params, dcplp, stop_pos, period):
        self.fig = plt.figure(0, figsize=(16, 9))
        self.ax = [self.fig.add_subplot(3, 4, 1),
                   self.fig.add_subplot(3, 4, 2),
                   self.fig.add_subplot(3, 4, 3),
                   self.fig.add_subplot(3, 4, 4),
                   self.fig.add_subplot(3, 4, 5),
                   self.fig.add_subplot(3, 4, 6),
                   self.fig.add_subplot(3, 4, 7),
                   self.fig.add_subplot(3, 4, 8),
                   self.fig.add_subplot(3, 4, 9),
                   self.fig.add_subplot(3, 4, 10),
                   self.fig.add_subplot(3, 4, 11),
                   self.fig.add_subplot(3, 4, 12)]

        self.region = [par.Rect() for _ in range(12)]
        self.fig.tight_layout()
        self.params = params
        self.fig.canvas.set_window_title(params.inst + ' m12' + period)

        self.m12 = m12
        self.dcplp = dcplp
        self.stop_pos = stop_pos

        self.art = []
        for i in range(12):
            self.art.append(artist_ctpmdif.Artist(
                m12, self.dcplp, self.ax[i], "art" + str(i), i))

        self.anim_interval = 10

        self.cur_pos = self.params.data_len
        self.show_future = False  # True

        self.fig.canvas.mpl_connect('key_press_event', self.press)
        self.fig.canvas.mpl_connect('close_event', self.handle_close)
        self.fig.canvas.mpl_connect('resize_event', self.on_resize)
        self.fig.canvas.mpl_connect('button_press_event', self.onclick)

        self.event_source = self.fig.canvas.new_timer()
        self.event_source.interval = self.anim_interval

        self.fig2 = plt.figure(1, figsize=(16, 9))
        self.ax2 = self.fig2.add_subplot(1, 1, 1)
        self.fig2.tight_layout()
        self.fig2.canvas.set_window_title(params.inst + ' bigpic' + period)
        self.region2 = par.Rect()

        self.art2 = artist_bigpic_ctpmdif.ArtistBigPicture(
            m12, dcplp, self.ax2, "big_pic", 7)
        self.fig2.canvas.mpl_connect('key_press_event', self.press_2)
        self.fig2.canvas.mpl_connect('close_event', self.handle_close)
        self.fig2.canvas.mpl_connect('resize_event', self.on_resize2)
        self.fig2.canvas.mpl_connect('button_press_event', self.onclick2)

        self.toggle = True

        self.ani1 = animation.FuncAnimation(self.fig, self.draw_frame_1, self.params.all_len,
                                            init_func=self.init_draw_1,
                                            interval=self.anim_interval,
                                            blit=True)
        self.ani2 = animation.FuncAnimation(self.fig2, self.draw_frame_2, self.params.all_len,
                                            init_func=self.init_draw_2,
                                            interval=self.anim_interval,
                                            blit=True)