title: Simple way to do a 3d plot interactively using Mayavi?
body: <p>Reading Mayavi's documentation "<a href="http://docs.enthought.com/mayavi/mayavi/building_applications.html" rel="nofollow noreferrer">http://docs.enthought.com/mayavi/mayavi/building_applications.html</a>" gets me real confused.</p>
  
  <p>My question is, if I just want a 3d plot that allows user interaction, for example, dragging a slider and change the content of the plot, I don't <strong>have</strong> to use Traits, right? By the documentation, the standard procedure is something like:</p>
  
  <pre><code>class visual(HasTraits):
      scene = ...
      view = View(...)
      @on_trait_change(...)
      def do_something()
          ...
  </code></pre>
  
  <p>I don't know what traits are. I don't even understand what's an attribute in a class that's defined outside of the constructor (it's a 'trait'?). </p>
  
  <p>Back to the original question, if I just wanted a 3d plot that's changeable, why don't I just directly do it? A working example is as follows:</p>
  
  <pre><code>import numpy as np
  from mayavi import mlab
  from matplotlib import pyplot as plt
  from matplotlib.widgets import Slider
  
  
  def slider_changed(val):
      s.mlab_source.scalars = np.asarray(x * (val + 1), 'd')
  
  # mayavi 3d plot
  x, y = np.mgrid[0:3:1,0:3:1]
  s = mlab.surf(x, y, np.asarray(x*0.1, 'd'))
  
  # a matplotlib slider
  plt.figure()
  ax = plt.subplot(1, 1, 1)
  slider = Slider(ax, valmin=0., valmax=1., label='test')
  slider.on_changed(slider_changed)
  
  plt.show()
  mlab.show()
  </code></pre>
  
  <p>Seems to me if I don't care about <strong>embedding</strong> the 3d plot in applications, this is a much simpler way to do it? A lot of the attributes of the 3d plot is manipulable through the attributes of <code>mlab_source</code>. I am using a matplotlib slider here as an example, but it seems it can be a pyqt UI or whatever. </p>
  
  <p>However, the documentation says </p>
  
  <blockquote>
    <p>All the different properties of the pipeline and pipeline objects are expressed as Traits, i.e. special attributes that can be visualized in dialogs and that fire callbacks when they are modified. In particular this means that when a visualization object is modified, the scene can update automatically.</p>
  </blockquote>
  
  <p>Does it mean if I wanted something that's automatically updated, I have to use Traits in the way it was described above?</p>