Ask Your Question
1

can I create isosurface contours from list data?

asked 2013-05-11 12:13:21 +0100

Young Lee gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-05-11 15:48:51 +0100

vdelecroix gravatar image

It seems not directly available within Sage but you can use matplotlib which is distributed with Sage. I found examples in the references of matplotlib 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 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')
edit flag offensive delete link more
0

answered 2013-05-14 06:17:39 +0100

Jason Grout gravatar image

You can use implicit_plot3d to do this sort of thing.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-05-11 12:13:21 +0100

Seen: 2,750 times

Last updated: May 14 '13