Guest User

Untitled

a guest
Aug 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. matplotlib and PyQt ploting a suface
  2. fig = pylab.figure()
  3. ax = Axes3D( fig )
  4. surf = ax.plot_surface( X, Y, Z, cmap=cm.gray_r, linewidth=0, antialiased=True )
  5. fig.canvas.set_window_title( "Distance" )
  6. pylab.show()
  7.  
  8. class ViewerForm(QMainWindow):
  9. def __init__(self, p_parent=None, p_data=None):
  10. QMainWindow.__init__( self, parent=p_parent )
  11.  
  12. self.main_frame = QWidget( )
  13. self.figure = pyplot.figure()
  14. self.axis = Axes3D( self.figure )
  15. self.canvas = FigureCanvas( self.figure )
  16. self.canvas.setParent( self.main_frame )
  17. self.mpl_toolbar = NavigationToolbar( self.canvas, self.main_frame )
  18.  
  19. self.X, self.Y = np.meshgrid( p_data[ "axis_x" ], p_data[ "axis_y" ] )
  20. self.Z = p_data[ "values_z" ]
  21.  
  22. self.surface = self.axis.plot_surface( self.X, self.Y, self.Z, cmap=cm.gray, linewidth=0, antialiased=True )
  23.  
  24. vbox = QVBoxLayout( )
  25. vbox.addWidget( self.canvas )
  26. vbox.addWidget( self.mpl_toolbar )
  27. self.main_frame.setLayout( vbox )
  28.  
  29. self.setCentralWidget( self.main_frame )
  30.  
  31. self.surface = self.axis.plot_surface( self.X, self.Y, self.Z, cmap=cm.gray, linewidth=0, antialiased=True )
  32. self.axis.mouse_init()
Add Comment
Please, Sign In to add comment