本文整理汇总了Python中mayavi.mlab.contour3d方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.contour3d方法的具体用法?Python mlab.contour3d怎么用?Python mlab.contour3d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mayavi.mlab
的用法示例。
在下文中一共展示了mlab.contour3d方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import contour3d [as 别名]
def main():
mu = np.array([1, 10, 20])
sigma = np.matrix([[20, 10, 10],
[10, 25, 1],
[10, 1, 50]])
np.random.seed(100)
data = np.random.multivariate_normal(mu, sigma, 1000)
values = data.T
kde = stats.gaussian_kde(values)
# Create a regular 3D grid with 50 points in each dimension
xmin, ymin, zmin = data.min(axis=0)
xmax, ymax, zmax = data.max(axis=0)
xi, yi, zi = np.mgrid[xmin:xmax:50j, ymin:ymax:50j, zmin:zmax:50j]
# Evaluate the KDE on a regular grid...
coords = np.vstack([item.ravel() for item in [xi, yi, zi]])
density = kde(coords).reshape(xi.shape)
# Visualize the density estimate as isosurfaces
mlab.contour3d(xi, yi, zi, density, opacity=0.5)
mlab.axes()
mlab.show()
示例2: plot_contour3d
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import contour3d [as 别名]
def plot_contour3d(self, **kwargs):
'''
use mayavi.mlab to plot 3d contour.
Parameter
---------
kwargs: {
'maxct' : float,max contour number,
'nct' : int, number of contours,
'opacity' : float, opacity of contour,
'widths' : tuple of int
number of replication on x, y, z axis,
}
'''
if not mayavi_installed:
self.__logger.warning("Mayavi is not installed on your device.")
return
# set parameters
widths = kwargs['widths'] if 'widths' in kwargs else (1, 1, 1)
elf_data, grid = self.expand_data(self.elf_data, self.grid, widths)
# import pdb; pdb.set_trace()
maxdata = np.max(elf_data)
maxct = kwargs['maxct'] if 'maxct' in kwargs else maxdata
# check maxct
if maxct > maxdata:
self.__logger.warning("maxct is larger than %f", maxdata)
opacity = kwargs['opacity'] if 'opacity' in kwargs else 0.6
nct = kwargs['nct'] if 'nct' in kwargs else 5
# plot surface
surface = mlab.contour3d(elf_data)
# set surface attrs
surface.actor.property.opacity = opacity
surface.contour.maximum_contour = maxct
surface.contour.number_of_contours = nct
# reverse axes labels
mlab.axes(xlabel='z', ylabel='y', zlabel='x') # 是mlab参数顺序问题?
mlab.outline()
mlab.show()
return
示例3: process
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import contour3d [as 别名]
def process(path):
mrc = mrcfile.open(path)
print(type(mrc.data))
obj = contour3d(mrc.data, contours=10)
obj.module_manager.source.save_output(savepath)
return obj
示例4: evolve_visual3d
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import contour3d [as 别名]
def evolve_visual3d(msnake, levelset=None, num_iters=20):
"""
Visual evolution of a three-dimensional morphological snake.
Parameters
----------
msnake : MorphGAC or MorphACWE instance
The morphological snake solver.
levelset : array-like, optional
If given, the levelset of the solver is initialized to this. If not
given, the evolution will use the levelset already set in msnake.
num_iters : int, optional
The number of iterations.
"""
from mayavi import mlab
# import matplotlib.pyplot as ppl
if levelset is not None:
msnake.levelset = levelset
fig = mlab.gcf()
mlab.clf()
src = mlab.pipeline.scalar_field(msnake.data)
mlab.pipeline.image_plane_widget(
src, plane_orientation='x_axes', colormap='gray')
cnt = mlab.contour3d(msnake.levelset, contours=[0.5])
@mlab.animate(ui=True)
def anim():
for i in range(num_iters):
msnake.step()
cnt.mlab_source.scalars = msnake.levelset
yield
anim()
mlab.show()
# Return the last levelset.
return msnake.levelset