本文整理汇总了Python中mayavi.mlab.outline函数的典型用法代码示例。如果您正苦于以下问题:Python outline函数的具体用法?Python outline怎么用?Python outline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outline函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: animateGIF
def animateGIF(filename, prices):
'''Creates a mayavi visualization of a pd DataFrame containing stock prices
Then uses MoviePy to animate and save as a gif
Inputs:
prices => a pd DataFrame, w/ index: dates; columns: company names
'''
#Because of mayavi requirements, replace dates and company names with integers
#until workaround is figured out
x_length, y_length = prices.shape
xTime = np.array([list(xrange(x_length)),] * y_length).transpose()
yCompanies = np.array([list(xrange(y_length)),] * x_length)
#Sort indexed prices by total return on last date
lastDatePrices = prices.iloc[-1]
lastDatePrices.sort_values(inplace=True)
sortOrder = lastDatePrices.index
zPrices = prices[sortOrder]
#Create mayavi2 object
dims = xTime.shape
fig = mlab.figure(bgcolor=(.4,.4,.4))
vis = mlab.surf(xTime, yCompanies, zPrices)
mlab.outline(vis)
mlab.orientation_axes(vis)
mlab.axes(vis, nb_labels=0, xlabel = 'Time', ylabel = 'Company', zlabel = 'Price')
# duration = 2 #Duration of the animation in seconds (will loop)
animation = mpy.VideoClip(make_frame, duration = 4).resize(1.0)
# animation.write_videofile('prototype_animation.mp4', fps=20)
animation.write_gif(filename, fps=20)
示例2: animateGIF
def animateGIF(filename, prices):
'''Creates a mayavi visualization of a pd DataFrame containing stock prices
Then uses MoviePy to animate and save as a gif
Inputs:
prices => a pd DataFrame, w/ index: dates; columns: company names
'''
#Imports mlab here to delay starting of mayavi engine until necessary
from mayavi import mlab
#Because of current mayavi requirements, replaces dates and company names with integers
x_length, y_length = prices.shape
xTime = np.array([list(xrange(x_length)),] * y_length).transpose()
yCompanies = np.array([list(xrange(y_length)),] * x_length)
#Sort indexed prices by total return on last date
lastDatePrices = prices.iloc[-1]
lastDatePrices.sort_values(inplace=True)
sortOrder = lastDatePrices.index
zPrices = prices[sortOrder]
#Create mayavi2 object
fig = mlab.figure(bgcolor=(.4,.4,.4))
vis = mlab.surf(xTime, yCompanies, zPrices)
mlab.outline(vis)
mlab.orientation_axes(vis)
mlab.axes(vis, nb_labels=0, xlabel = 'Time', ylabel = 'Company', zlabel = 'Price')
animation = mpy.VideoClip(make_frame, duration = 4).resize(1.0)
animation.write_gif(filename, fps=20)
示例3: visualization3D_notimage
def visualization3D_notimage(image3D):
"""
:param image3D: image object from readDirWithBinaryDAta
:return:
"""
s=image3D
src = mlab.pipeline.scalar_field(image3D)
src.spacing=[1,1,5]
src.update_image_data = (1,1,5)
'''
mlab.pipeline.image_plane_widget(src,
plane_orientation='x_axes',
slice_index=1,
colormap='black-white'
)
mlab.pipeline.image_plane_widget(src,
plane_orientation='z_axes',
slice_index=1,
colormap='black-white'
)
'''
mlab.pipeline.iso_surface(src, contours=[0.5,1], opacity=1,colormap='black-white')
mlab.outline()
mlab.show()
示例4: labels
def labels(self):
'''
Add 3d text to show the axes.
'''
fontsize = max(self.xrang, self.yrang)/40.
tcolor = (1,1,1)
mlab.text3d(self.xrang/2,-40,self.zrang+40,'R.A.',scale=fontsize,orient_to_camera=True,color=tcolor)
mlab.text3d(-40,self.yrang/2,self.zrang+40,'Decl.',scale=fontsize,orient_to_camera=True,color=tcolor)
mlab.text3d(-40,-40,self.zrang/2-10,'V (km/s)',scale=fontsize,orient_to_camera=True,color=tcolor)
# Label the coordinates of the corners
# Lower left corner
ra0 = self.extent[0]; dec0 = self.extent[2]
c = coord.ICRS(ra=ra0, dec=dec0, unit=(u.degree, u.degree))
RA_ll = str(int(c.ra.hms.h))+'h'+str(int(c.ra.hms.m))+'m'+str(round(c.ra.hms.s,1))+'s'
mlab.text3d(0,-20,self.zrang+20,RA_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
DEC_ll = str(int(c.dec.dms.d))+'d'+str(int(abs(c.dec.dms.m)))+'m'+str(round(abs(c.dec.dms.s),1))+'s'
mlab.text3d(-80,0,self.zrang+20,DEC_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
# Upper right corner
ra0 = self.extent[1]; dec0 = self.extent[3]
c = coord.ICRS(ra=ra0, dec=dec0, unit=(u.degree, u.degree))
RA_ll = str(int(c.ra.hms.h))+'h'+str(int(c.ra.hms.m))+'m'+str(round(c.ra.hms.s,1))+'s'
mlab.text3d(self.xrang,-20,self.zrang+20,RA_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
DEC_ll = str(int(c.dec.dms.d))+'d'+str(int(abs(c.dec.dms.m)))+'m'+str(round(abs(c.dec.dms.s),1))+'s'
mlab.text3d(-80,self.yrang,self.zrang+20,DEC_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
# V axis
if self.extent[5] > self.extent[4]:
v0 = self.extent[4]; v1 = self.extent[5]
else:
v0 = self.extent[5]; v1 = self.extent[4]
mlab.text3d(-20,-20,self.zrang,str(round(v0,1)),scale=fontsize,orient_to_camera=True,color=tcolor)
mlab.text3d(-20,-20,0,str(round(v1,1)),scale=fontsize,orient_to_camera=True,color=tcolor)
mlab.axes(self.field, ranges=self.extent, x_axis_visibility=False, y_axis_visibility=False, z_axis_visibility=False)
mlab.outline()
示例5: _plot_max_Value
def _plot_max_Value( self ):
X = self.X_hf[:, 0]
Y = self.Y_hf[:, 0]
Z = self.Z_hf[:, 0]
plot_col = getattr( self, self.plot_column )[:, 0]
scale = 1 / max( plot_col )
# if self.plot_column == 'n_tex':
# plot_col = where( plot_col < 0, 0, plot_col )
mlab.figure( figure = "SFB532Demo",
bgcolor = ( 1.0, 1.0, 1.0 ),
fgcolor = ( 0.0, 0.0, 0.0 ) )
mlab.points3d( X, Y, ( -1.0 ) * Z, plot_col,
# colormap = "gist_rainbow",
# colormap = "Reds",
colormap = "copper",
mode = "cube",
scale_factor = scale )
mlab.outline()
mlab.scalarbar( title = self.plot_column, orientation = 'vertical' )
mlab.show
示例6: PlotHorizon3d
def PlotHorizon3d(tss):
"""
Plot a list of horizons.
Parameters
----------
tss : list of trappedsurface
All the trapped surfaces to visualize.
"""
from mayavi import mlab
cmaps = ['bone', 'jet', 'hot', 'cool', 'spring', 'summer', 'winter']
assert len(cmaps) > len(tss)
extents = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
for ts, cm in zip(tss, cmaps):
mlab.mesh(ts.X, ts.Y, ts.Z, colormap=cm, opacity=0.4)
extents[0] = min(extents[0], np.min(ts.X))
extents[1] = max(extents[1], np.max(ts.X))
extents[2] = min(extents[2], np.min(ts.Y))
extents[3] = max(extents[3], np.max(ts.Y))
extents[4] = min(extents[4], np.min(ts.Z))
extents[5] = max(extents[5], np.max(ts.Z))
mlab.axes(extent=extents)
mlab.outline(extent=extents)
mlab.show()
示例7: displayDensity
def displayDensity(self, densityValues):
self.numberOfElectrons(densityValues)
source = mlab.pipeline.scalar_field(self.x, self.y, self.z,
densityValues)
densityPlot = mlab.pipeline.image_plane_widget(source,
colormap="hot",opacity = 1, transparent=True,
plane_orientation='x_axes',vmin = self.vmin,
vmax = self.vmax*0.01,
slice_index=20,)
densityPlot = mlab.pipeline.image_plane_widget(source,
colormap="hot", opacity = 1,transparent=True,vmin = self.vmin,
vmax = self.vmax*0.01,
plane_orientation='y_axes',
slice_index=20,)
densityPlot = mlab.pipeline.image_plane_widget(source,
colormap="hot", opacity = 1, transparent=True, vmin = self.vmin,
vmax = self.vmax*0.01,
plane_orientation='z_axes',
slice_index=20,)
mlab.outline()
# mlab.axes()
return densityPlot.mlab_source
示例8: _showSimple
def _showSimple():
maxInterpolPts = 10
def interpolateSection(section):
sStart = section.getDistalNPA4()
sEnd = section.getProximalNPA4()
length = section.getLength()
rad = min(section.d_r, section.p_r)
n = min( max( int( lToRRatio * length / rad ), 1 ), maxInterpolPts)
jVecSteps = ( sEnd-sStart ) / n
intPts = [ sStart + k*jVecSteps for k in range(0,n) ]
return intPts
lbs = []
for morph in self.morphs:
lb = Flatten( ListBuilderSectionVisitor(functor=interpolateSection, morph=morph ) () )
lbs.extend( lb )
pts = numpy.array( lbs )
x = pts[:, 0]
y = pts[:, 1]
z = pts[:, 2]
s = pts[:, 3]
mlab.points3d(x, y, z, s, colormap=self.colormap, scale_factor=self.scale_factor)
mlab.outline()
示例9: plot3D
def plot3D(name, X, Y, Z, zlabel):
"""
Plots a 3d surface plot of Z using the mayavi mlab.mesh function.
Parameters
----------
name: string
The name of the figure.
X: 2d ndarray
The x-axis data.
Y: 2d ndarray
The y-axis data.
Z: 2d nd array
The z-axis data.
zlabel: The title that appears on the z-axis.
"""
mlab.figure(name)
mlab.clf()
plotData = mlab.mesh(X/(np.max(X) - np.min(X)),
Y/(np.max(Y) - np.min(Y)),
Z/(np.max(Z) - np.min(Z)))
mlab.outline(plotData)
mlab.axes(plotData, ranges=[np.min(X), np.max(X),
np.min(Y), np.max(Y),
np.min(Z), np.max(Z)])
mlab.xlabel('Space ($x$)')
mlab.ylabel('Time ($t$)')
mlab.zlabel(zlabel)
示例10: visualizePrices
def visualizePrices(prices):
'''Creates a mayavi visualization of a pd DataFrame containing stock prices
Inputs:
prices => a pd DataFrame, w/ index: dates; columns: company names
'''
#Because of mayavi requirements, replace dates and company names with integers
#until workaround is figured out
x_length, y_length = prices.shape
xTime = np.array([list(xrange(x_length)),] * y_length).transpose()
yCompanies = np.array([list(xrange(y_length)),] * x_length)
#Sort indexed prices by total return on last date
lastDatePrices = prices.iloc[-1]
lastDatePrices.sort_values(inplace=True)
sortOrder = lastDatePrices.index
zPrices = prices[sortOrder]
#Create mayavi2 object
dims = xTime.shape
fig = mlab.figure(bgcolor=(.4,.4,.4))
vis = mlab.surf(xTime, yCompanies, zPrices)
mlab.outline(vis)
mlab.orientation_axes(vis)
#mlab.title('S&P 500 Market Data Visualization', size = .25)
mlab.axes(vis, nb_labels=0, xlabel = 'Time', ylabel = 'Company', zlabel = 'Price')
#Functionality to be added:
# cursor3d = mlab.points3d(0., 0., 0., mode='axes',
# color=(0, 0, 0),
# scale_factor=20)
#picker = fig.on_mouse_pick(picker_callback)
mlab.show()
示例11: etsIntro
def etsIntro():
x, y = np.ogrid[-2:2:20j, -2:2:20j]
z = x * np.exp( - x**2 - y**2)
pl = mlab.surf(x, y, z, warp_scale="auto")
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(pl)
示例12: plot_3D
def plot_3D( self ):
x = self.compute3D_plot[0]
y = self.compute3D_plot[1]
z = self.compute3D_plot[2]
# print x_axis, y_axis, z_axis
if self.autowarp_bool:
x = x / x[-1]
y = y / y[-1]
z = z / z[-1] * self.z_scale
mlab.surf( x, y , z, representation = 'wireframe' )
engine = Engine()
engine.start()
if len( engine.scenes ) == 75.5:
engine.new_scene()
surface = engine.scenes[0].children[0].children[0].children[0].children[0].children[0]
surface.actor.mapper.scalar_range = np.array( [ 6.97602671, 8.8533387 ] )
surface.actor.mapper.scalar_visibility = False
scene = engine.scenes[0]
scene.scene.background = ( 1.0, 1.0, 1.0 )
surface.actor.property.specular_color = ( 0.0, 0.0, 0.0 )
surface.actor.property.diffuse_color = ( 0.0, 0.0, 0.0 )
surface.actor.property.ambient_color = ( 0.0, 0.0, 0.0 )
surface.actor.property.color = ( 0.0, 0.0, 0.0 )
surface.actor.property.line_width = 1.
scene.scene.isometric_view()
mlab.xlabel( self.x_name3D )
mlab.ylabel( self.y_name3D )
mlab.outline()
mlab.show()
示例13: plot_mayavi
def plot_mayavi(self):
"""Use mayavi to plot a phenotype phase plane in 3D.
The resulting figure will be quick to interact with in real time,
but might be difficult to save as a vector figure.
returns: mlab figure object"""
from mayavi import mlab
figure = mlab.figure(bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))
figure.name = "Phenotype Phase Plane"
max = 10.0
xmax = self.reaction1_fluxes.max()
ymax = self.reaction2_fluxes.max()
zmax = self.growth_rates.max()
xgrid, ygrid = meshgrid(self.reaction1_fluxes, self.reaction2_fluxes)
xgrid = xgrid.transpose()
ygrid = ygrid.transpose()
xscale = max / xmax
yscale = max / ymax
zscale = max / zmax
mlab.surf(xgrid * xscale, ygrid * yscale, self.growth_rates * zscale,
representation="wireframe", color=(0, 0, 0), figure=figure)
mlab.mesh(xgrid * xscale, ygrid * yscale, self.growth_rates * zscale,
scalars=self.shadow_prices1 + self.shadow_prices2,
resolution=1, representation="surface", opacity=0.75,
figure=figure)
# draw axes
mlab.outline(extent=(0, max, 0, max, 0, max))
mlab.axes(opacity=0, ranges=[0, xmax, 0, ymax, 0, zmax])
mlab.xlabel(self.reaction1_name)
mlab.ylabel(self.reaction2_name)
mlab.zlabel("Growth rates")
return figure
示例14: showContour
def showContour(self):
"""
Display real space model using contour
"""
mlab.contour3d(self.array, contours=8, opacity=0.3, transparent=True)
mlab.outline()
mlab.show()
示例15: plot_potential_cartesian
def plot_potential_cartesian(self, fig=None, x=None, y=None, z=None):
if not self.USE_MAYAVI:
return None
if fig is None:
fig = mlab.figure('Potential')#, bgcolor=(0, 0, 0))
#fig = mlab.figure('Potential', bgcolor=(0, 0, 0))
else:
mlab.figure(fig, bgcolor=fig.scene.background)
if x is None:
x = np.linspace(1e-9, 5e-8, num=100, endpoint=True)
if y is None:
y = np.linspace(1e-9, 5e-8, num=100, endpoint=True)
if z is None:
z = np.linspace(1e-9, 5e-8, num=100, endpoint=True)
x_grid, y_grid, z_grid = np.meshgrid(x, y, z)
r_grid, theta_grid, phi_grid = Vectors3D.cartesian_to_spherical(x_grid, y_grid, z_grid)
volumetric_data = self.potential_on_grid(r_grid, theta_grid, phi_grid)
#volumetric_data = 1 / (x_grid**2 + y_grid**2 + z_grid**2)
#mlab.contour3d(x_grid, y_grid, z_grid, volumetric_data, colormap='jet')
#mlab.contour3d(volumetric_data, colormap='jet')
source = mlab.pipeline.scalar_field(volumetric_data)
min = volumetric_data.min()
max = volumetric_data.max()
vol = mlab.pipeline.volume(source)
#vol = mlab.pipeline.volume(source, vmin=min + 0.65 * (max - min),
# vmax=min + 0.9 * (max - min))
mlab.outline()
return fig