import numpy as np from numpy import sin, cos, pi from skimage import measure import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def fun(x, y, z): return cos(x) + cos(y) + cos(z) x, y, z = pi*np.mgrid[-1:1:31j, -1:1:31j, -1:1:31j] vol = fun(x, y, z) verts, faces = measure.marching_cubes(vol, 0, spacing=(0.1, 0.1, 0.1)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_trisurf(verts[:, 0], verts[:,1], faces, verts[:, 2], cmap='Spectral', lw=1) plt.show()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question