How to display a float matrix as elevation values in a 3D plot in Python?
Question: I currently have a heat map which is a 2D float matrix (list of lists of
floats to be accurate), and I can display it in 2D with matplotlib fairly
easily, but I would like to display it in a 3D plot such that the column and
row indices can by the X and Y values respectively, and the values in the
matrix are Z (elevation) values. What can I use to do that? I tried using
Axes3D but it didn't seem very suitable (or maybe I was using it wrong?). What
I am looking to do is conceptually very simple, to pretend the matrix is a DEM
and display it as such.

Also if possible I would like to be able to change viewing angles on-the-fly,
without having to re-generate the plot.

Any ideas?

These two questions are related but don't quite answer my question:

[3d plotting with
python](http://stackoverflow.com/questions/8841827/3d-plotting-with-python)

[Python: 3D contour from a 2D image - pylab and
contourf](http://stackoverflow.com/questions/15581935/python-3d-contour-
from-a-2d-image-pylab-and-contourf)

NB: The float matrix is rather large, typically 100x100 or more, and the last
time I tried to plot it in 3D my system ran out of memory and started
thrashing.


Answer: Your use case seems like it is tailor made for mayavi/mlab, which has a
function that does exactly what you are asking and by default permits
interactive 3D rotation:

    
    
    import numpy as np; from mayavi import mlab
    data = np.random.random((100,100))
    mlab.surf(data)
    mlab.show()
    

