单击时更新轴

时间:2018-04-20 10:15:10

标签: python-3.x matplotlib pyqt5

我想在点击其中一个轴时更新轴。首先,我有我创建exes的Orthoview3D类和Orthocanvas,我在其中创建修复并绘制数据.nii。但是这三个轴是静态的,我希望在运行时更新动态。

class Orthoview3D():
    def __init__ (self, fig, data):
        data = np.asanyarray(data)
        xrows, xcols = 2,2
        self._axes = [fig.add_subplot(xrows, xcols, i + 1) for i in range(xrows * xcols)
        fig.set_size_inches((8, 8), forward=True)

class OrthoCanvas(FigureCanvas):
    def __init__(self, parent=None, width=5, height=4, dpi=100):
        super(Orthoview3D, self).__init__()
        fig = Figure(figsize=(width, height), dpi=dpi)
        self._figs = set([a.figure for a in self.axes])
        data = load_nii('d_crop_mni_s01_t1w_hires_defaced_MNI.nii')
        data_read = read_img_data(data)
        for fig in self._figs:
            fig.canvas.mpl_connect('scroll_event', self._on_scroll)
            fig.canvas.mpl_connect('motion_notify_event', self._on_mouse)
            fig.canvas.mpl_connect('button_press_event', self._on_mouse)
            fig.canvas.mpl_connect('key_press_event', self._on_keypress)
            fig.canvas.mpl_connect('close_event', self._cleanup)   

        ortho = OrthoView3D(fig)
        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                                   QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

错误:RuntimeError: super-class __init__() of type OrthoCanvas was never called

0 个答案:

没有答案