매우
덕분에 당신이 (적어도하기 matplotlib 1.0.1 및 PyQt는 4.8) 찾고있는 것을 발견한다 :
class MplPlot3dCanvas(FigureCanvas):
def __init__(self):
self.surfs = [] # [{"xx":,"yy:","val:"}]
self.fig = Figure()
self.fig.suptitle("this is the figure title", fontsize=12)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QSizePolicy.Expanding,
QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.ax = Axes3D(self.fig) # Canvas figure must be created for mouse rotation
self.ax.set_xlabel('row (m CCD)')
self.ax.set_ylabel('col (m CCD)')
self.ax.set_zlabel('Phi (m)')
self.format_coord_org = self.ax.format_coord
self.ax.format_coord = self.report_pixel
def report_pixel(self, xd, yd):
s = self.format_coord_org(xd, yd)
s = s.replace(",", " ")
return s
def update_view(self):
for plt in self.plots:
# del plt
self.ax.collections.remove(plt)
self.plots = []
for surf in self.surfs:
plt = self.ax.plot_surface(surf["xx"], surf["yy"], surf["val"], rstride=5, cstride=5, cmap=cm.jet, linewidth=1, antialiased=True)
self.plots.append(plt)
self.draw()
class MplPlot3dView(QWidget):
def __init__(self, parent = None):
super(MplPlot3dView, self).__init__(parent)
self.canvas = MplPlot3dCanvas()
self.toolbar = NavigationToolbar(self.canvas, self.canvas)
self.vbox = QVBoxLayout()
self.vbox.addWidget(self.canvas)
self.vbox.addWidget(self.toolbar)
self.setLayout(self.vbox)
self.to_update = False
그런 다음, 당신은 단지 추가해야 귀하의 QtaWidget에 QWidget을 추가하고 그것을 새로운 클래스 MplPlot3dView로 승격하십시오 (그렇게하는 방법에 대해 네트워크에서 쉽게 찾을 수 있습니다).