Exemplo n.º 1
0
    def on_motion(self, event):
        if self.press is None:
            return
        if event.inaxes not in [self.line1.axes, self.line2.axes]:
            return
        if event.inaxes == self.line1.axes:
            '''
            实现ax1到ax2的链接
            '''
            x0, y0, mx, my = self.press  # y0表示on_press选取上的line1的坐标
            y0[self.lastind] = event.ydata  #上表示改变其中选取的那个点的坐标,其他坐标不变
            print(x0, y0, mx, my)
            self.line1.set_ydata(y0)  #改变line1中个点的y坐标(实际只变动了1维)
            iteration_y = np.array(self.line1.get_ydata()).reshape(1, -1)
            Data_new = self.pca.transform(iteration_y)  #根据line1的坐标确定line2的坐标
            self.line2.set_xdata(Data_new[:, 0].reshape(-1, 1))
            self.line2.set_ydata(Data_new[:, 1].reshape(-1, 1))
            print('123', self.Normal.InverseNormalize(y0))

            l = len(self.Normal.InverseNormalize(y0))
            m = ["0"] * l
            name = m + self.Normal.InverseNormalize(y0)
            Mytable = FileFormat.data_table(name)
            y1 = self.model(Mytable, 0)  #确定选中线的颜色
            print('y1', y1)

            self.line1.set_color(self.scalarMap.to_rgba(y1))
            self.line2.set_color(self.scalarMap.to_rgba(y1))

        self.fig.canvas.draw()