Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You do not need to <code>plt.show()</code> if it is an animated (interactive) plot. You also want interactive set to True, not False which is the same as calling <code>ion()</code> in your 2d example. Also, you need to <code>remove()</code> the surface plots from previous frames if you do not want to see them all.</p> <p>Otherwise you were pretty close.</p> <p>This works for me:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter import matplotlib, time class plot3dClass( object ): def __init__( self, systemSideLength, lowerCutoffLength ): self.systemSideLength = systemSideLength self.lowerCutoffLength = lowerCutoffLength self.fig = plt.figure() self.ax = self.fig.add_subplot( 111, projection='3d' ) self.ax.set_zlim3d( -10e-9, 10e9 ) rng = np.arange( 0, self.systemSideLength, self.lowerCutoffLength ) self.X, self.Y = np.meshgrid(rng,rng) self.ax.w_zaxis.set_major_locator( LinearLocator( 10 ) ) self.ax.w_zaxis.set_major_formatter( FormatStrFormatter( '%.03f' ) ) heightR = np.zeros( self.X.shape ) self.surf = self.ax.plot_surface( self.X, self.Y, heightR, rstride=1, cstride=1, cmap=cm.jet, linewidth=0, antialiased=False ) # plt.draw() maybe you want to see this frame? def drawNow( self, heightR ): self.surf.remove() self.surf = self.ax.plot_surface( self.X, self.Y, heightR, rstride=1, cstride=1, cmap=cm.jet, linewidth=0, antialiased=False ) plt.draw() # redraw the canvas time.sleep(1) matplotlib.interactive(True) p = plot3dClass(5,1) for i in range(2): p.drawNow(np.random.random(p.X.shape)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload