Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6744317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:04:09+00:00 2026-05-26T12:04:09+00:00

I created a 3D plot using matplotlib as this: fig = pylab.figure() ax =

  • 0

I created a 3D plot using matplotlib as this:

fig = pylab.figure()
ax = Axes3D( fig )
surf = ax.plot_surface( X, Y, Z, cmap=cm.gray_r, linewidth=0, antialiased=True )
fig.canvas.set_window_title( "Distance" )
pylab.show()

It’s fantastic: I see the surface in grays-cale and I can interact with it ( turn the surface, move plot, … )

Now I need to put this plot in a PyQt form. I created a class inherit from QMainWindow doing this:

class ViewerForm(QMainWindow):
   def __init__(self, p_parent=None, p_data=None):
      QMainWindow.__init__( self, parent=p_parent )

      self.main_frame = QWidget( )
      self.figure = pyplot.figure()
      self.axis = Axes3D( self.figure )
      self.canvas = FigureCanvas( self.figure )
      self.canvas.setParent( self.main_frame )
      self.mpl_toolbar = NavigationToolbar( self.canvas, self.main_frame )

      self.X, self.Y = np.meshgrid( p_data[ "axis_x" ], p_data[ "axis_y" ] )
      self.Z = p_data[ "values_z" ]

      self.surface = self.axis.plot_surface( self.X, self.Y, self.Z, cmap=cm.gray, linewidth=0, antialiased=True )

      vbox = QVBoxLayout( )
      vbox.addWidget( self.canvas )
      vbox.addWidget( self.mpl_toolbar )
      self.main_frame.setLayout( vbox )

      self.setCentralWidget( self.main_frame )

When I show this form I can see the surface in gray-scale as the first plot but I can’t interact with this: I can’t move the surface clicking with mouse. Anyone can say me what I’m doing wrong or what I misunderstood?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:04:10+00:00Added an answer on May 26, 2026 at 12:04 pm

    I had this before and it confused me a lot. Zhenya is right about the mouse clicking.

    By default, control of the plot by mouse is turned off when the axis is cleared/replotted. I have no idea quite why this would be so, but you need to initiate mouse interactions again:

    self.surface = self.axis.plot_surface( self.X, self.Y, self.Z, cmap=cm.gray, linewidth=0, antialiased=True )
    self.axis.mouse_init()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get a plot that fits the data automatically using matplotlib. This
I need to plot some data in various forms. Currently I'm using Matplotlib and
I am using tkinter to write a simple GUI program to plot figure of
I created a histogram plot using data from a file and no problem. Now
I have created a 3d map using rgl.surface(), mainly following Shane's answer in this
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
I wish to recreate this graph: (from here ) Using R base graphics. I
Okay to get started I am using Jquery-Flot to plot a radial graph I
I'm using Core Plot 0.9 in my first iPad project. I need to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.