ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 May 2013 23:17:39 -0500can I create isosurface contours from list data?http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/I've recently started playing with sage 3d plotting. I was wondering if there was any way I can make 3D isosurface contour plots from list data. I'm able to take 2D matrix data and make 3D surface plots using list_plot3d. But I want to take 3D matrix data and make isosurface contour plots in a way similar to mayavi's contour3d function.Sat, 11 May 2013 05:13:21 -0500http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/Answer by vdelecroix for <p>I've recently started playing with sage 3d plotting. I was wondering if there was any way I can make 3D isosurface contour plots from list data. I'm able to take 2D matrix data and make 3D surface plots using list_plot3d. But I want to take 3D matrix data and make isosurface contour plots in a way similar to mayavi's contour3d function.</p>
http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/?answer=14911#post-id-14911It seems not directly available within Sage but you can use matplotlib which is distributed with Sage. I found [examples in the references of matplotlib](http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#contour-plots) that seems related to what you are looking for. You can adapt them for Sage:
- in the notebook by replacing the last line **plt.show()** with **plt.savefig('my_fig.png')**
- in the console by replacing the last line **plt.show()** with **plt.savefig('my_fig.png')** and then viewing it with your prefered image viewer (it was mentioned [there](http://ask.sagemath.org/question/2516/matplotlib-x11-window) that the show method for matplotlib is broken)
The following works for me
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm)
ax.clabel(cset, fontsize=9, inline=1)
plt.savefig('contour_plot.png')
Sat, 11 May 2013 08:48:51 -0500http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/?answer=14911#post-id-14911Answer by Jason Grout for <p>I've recently started playing with sage 3d plotting. I was wondering if there was any way I can make 3D isosurface contour plots from list data. I'm able to take 2D matrix data and make 3D surface plots using list_plot3d. But I want to take 3D matrix data and make isosurface contour plots in a way similar to mayavi's contour3d function.</p>
http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/?answer=12071#post-id-12071You can use [implicit_plot3d](http://www.sagemath.org/doc/reference/plot3d/sage/plot/plot3d/implicit_plot3d.html) to do this sort of thing.Mon, 13 May 2013 23:17:39 -0500http://ask.sagemath.org/question/10113/can-i-create-isosurface-contours-from-list-data/?answer=12071#post-id-12071