Don't like ads? PRO users don't see any ads ;-)
Guest

mayavi plot3d

By: a guest on Apr 30th, 2012  |  syntax: Python  |  size: 2.14 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In [1]: from __future__ import division
  2.  
  3. In [2]: from mayavi import mlab
  4.  
  5. In [3]: from numpy import pi, sin, cos, mgrid, ogrid
  6.  
  7. In [4]: [u1,v1] = ogrid[0:8:5j,0:2*pi:5j]
  8.  
  9. In [5]: [t3,t4] = ogrid[1:1:5j,1:1:5j]
  10.  
  11. In [6]: x = u1 * sin(v1)
  12.  
  13. In [7]: y = u1 * cos(v1)
  14.  
  15. In [8]: z = 5 * t3 * t4
  16.  
  17. In [9]: mlab.plot3d(x,y,z)
  18. ---------------------------------------------------------------------------
  19. ValueError                                Traceback (most recent call last)
  20. /home/lblasc/<ipython-input-11-783c3fe02c12> in <module>()
  21. ----> 1 mlab.plot3d(x,y,z)
  22.  
  23. /usr/lib/python2.7/dist-packages/mayavi/tools/helper_functions.pyc in the_function(*args, **kwargs)
  24.      32 def document_pipeline(pipeline):
  25.      33     def the_function(*args, **kwargs):
  26. ---> 34         return pipeline(*args, **kwargs)
  27.      35
  28.      36     if hasattr(pipeline, 'doc'):
  29.  
  30. /usr/lib/python2.7/dist-packages/mayavi/tools/helper_functions.pyc in __call__(self, *args, **kwargs)
  31.      77             scene.disable_render = True
  32.      78         # Then call the real logic
  33.  
  34. ---> 79         output = self.__call_internal__(*args, **kwargs)
  35.      80         # And re-enable the rendering, if needed.
  36.  
  37.      81         if scene is not None:
  38.  
  39. /usr/lib/python2.7/dist-packages/mayavi/tools/helper_functions.pyc in __call_internal__(self, *args, **kwargs)
  40.     534         filters.
  41.     535         """
  42. --> 536         self.source = self._source_function(*args, **kwargs)
  43.    537         kwargs.pop('name', None)
  44.    538         self.store_kwargs(kwargs)
  45.  
  46. /usr/lib/python2.7/dist-packages/mayavi/tools/sources.pyc in line_source(*args, **kwargs)
  47.   1169
  48.   1170     data_source = MLineSource()
  49. -> 1171     data_source.reset(x=x, y=y, z=z, scalars=s)
  50.   1172
  51.   1173     name = kwargs.pop('name', 'LineSource')
  52.  
  53. /usr/lib/python2.7/dist-packages/mayavi/tools/sources.pyc in reset(self, **traits)
  54.    489         else:
  55.    490             points = np.c_[x.ravel(), y.ravel(), z.ravel()].ravel()
  56. --> 491             points.shape = (len(x), 3)
  57.    492             self.set(points=points, trait_change_notify=False)
  58.    493
  59.  
  60. ValueError: total size of new array must be unchanged