title: Plotting a large number of stacked spheres generated from python-- mayavi? paraview and pyevtk? How to transmute .npy to .vtk?
body: <p>I want to produce plots like this, except with many more particles. Matplotlib is woefully inadequate.  </p>
  
  <p><a href="https://i.stack.imgur.com/tWZqK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tWZqK.png" alt="from google"></a></p>
  
  <p>Right now I am using mayavi in python 3.5 running through a jupyter notebook. As I need to plot 5x10^5 spheres it will not be practical, since time is a limiting factor already at 2x10^4 spheres. </p>
  
  <p>Here is my python code to produce the mayavi plot. I have a numpy array of values [a,r,x,y,z]. It's not relevant what the first quantity is for this problem. </p>
  
  <pre><code>"""VISUALIZATION WITH MAYAVI"""
  #I think this is too slow to be practical. 
  #view particles with mayavi
  import mayavi
  from mayavi import mlab
  %gui qt
  
  def plot_sphere(p):  #feed it p and get back a sphere \n",
      t1,R,a,b,c = p
      [phi,theta] = np.mgrid[0:2*np.pi:12j,0:np.pi:12j]  #increase the numbers before j for better resolution but more time
      x = R*np.cos(phi)*np.sin(theta) + a
      y = R*np.sin(phi)*np.sin(theta) + b
      z = R*np.cos(theta) + c
      return mlab.mesh(x, y, z)  
  
  #run s over all particles and plot it
  def view(particles): 
      for p in particles:
          plot_sphere(p)
  
  view(spheres)
  </code></pre>
  
  <p>This code produces plots like this:</p>
  
  <p><a href="https://i.stack.imgur.com/EN2f1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EN2f1.png" alt="enter image description here"></a></p>
  
  <p>I have been told I should look into writing my numpy arrays to .vtk files using evtk, then visualizing these in paraview. I downloaded paraview and read <a href="https://pyscience.wordpress.com/2014/09/06/numpy-to-vtk-converting-your-numpy-arrays-to-vtk-arrays-and-files/" rel="nofollow noreferrer">this</a>, but perhaps my version of python is limiting me? First, install pyevtk-- okay: 
  I tried  conda install -c opengeostat pyevtk=1.0.0, but it fails due to incompatibility with my python version. I looked for details but could not find any. </p>
  
  <p>Next I downloaded the repository [here][<a href="https://pypi.python.org/pypi/PyEVTK/1.0.0]" rel="nofollow noreferrer">https://pypi.python.org/pypi/PyEVTK/1.0.0]</a>, then used pip to install it successfully. </p>
  
  <p>Next I put evtk.py, vtk.py, hl.py, and xml.py, and tried some examples in the repository-- none of them work. Seemingly there is some problem with</p>
  
  <pre><code>from .vtk import *
  </code></pre>
  
  <p>type commands. I tried replacing all of these in the four .py files with </p>
  
  <pre><code>from evtk import vtk 
  from vtk import * 
  </code></pre>
  
  <p>and such, but no luck. Long story short, I can't get pyevtk working to export my numpy arrays as .vtk files. I could use some help in this regard, or better yet I would love a different option to get my numpy arrays rendered by paraview. Any help is appreciated ! </p>