Ask Your Question
1

can I create isosurface contours from list data?

asked 11 years ago

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.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 11 years ago

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')
Preview: (hide)
link
0

answered 11 years ago

Jason Grout gravatar image

You can use implicit_plot3d to do this sort of thing.

Preview: (hide)
link

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: 11 years ago

Seen: 2,786 times

Last updated: May 14 '13