本文整理汇总了Python中mayavi.mlab.text3d函数的典型用法代码示例。如果您正苦于以下问题:Python text3d函数的具体用法?Python text3d怎么用?Python text3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text3d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawArrows
def drawArrows(file1, file2, figure, bbox, index, descendant):
"""
Draw an 'arrow' from the cell 'index' to 'descendant'
'descendant' is assumed to be a 1D np.array with size 0, 1 or 2.
"""
#load the center of mass position
if descendant.size > 0 and descendant[0] != 0:
com1 = file1["features"][str(index[0])]["com"][:]
com2 = file2["features"][str(descendant[0])]["com"][:]
#write the cell label as text
mlab.text3d(com1[2]-bbox[2]+1,com1[1]-bbox[1]+1,com1[0]-bbox[0]+1, str(index), color=(1,1,1), figure=figure)
#plot a point where the current cell is
mlab.points3d([com1[2]-bbox[2]+1],[com1[1]-bbox[1]+1],[com1[0]-bbox[0]+1],color=(0,0,1), figure=figure)
#plot a line to the descendant's center
mlab.plot3d([com1[2]-bbox[2]+1,com2[2]-bbox[2]+1],
[com1[1]-bbox[1]+1,com2[1]-bbox[1]+1],
[com1[0]-bbox[0]+1,com2[0]-bbox[0]+1],
tube_radius=0.2, color=(1,0,0), figure=figure)
#plot a second line, if there is a split
if descendant.size == 2:
com3 = file2["features"][str(descendant[1])]["com"][:]
mlab.plot3d([com1[2]-bbox[2]+1,com3[2]-bbox[2]+1],
[com1[1]-bbox[1]+1,com3[1]-bbox[1]+1],
[com1[0]-bbox[0]+1,com3[0]-bbox[0]+1],
tube_radius=0.2, color=(1,0,0), figure=figure)
示例2: render
def render(self, scale_factor=1.0, text_scale=1.0, **kwargs):
import mayavi.mlab as mlab
# disabling the rendering greatly speeds up this for loop
self.figure.scene.disable_render = True
positions = []
for label in self.lmark_group:
p = self.lmark_group[label]
for i, p in enumerate(p.points):
positions.append(p)
l = '%s_%d' % (label, i)
# TODO: This is due to a bug in mayavi that won't allow
# rendering text to an empty figure
mlab.points3d(p[0], p[1], p[2], scale_factor=scale_factor)
mlab.text3d(p[0], p[1], p[2], l, figure=self.figure,
scale=text_scale)
positions = np.array(positions)
os = np.zeros_like(positions)
os[:, 2] = 1
mlab.quiver3d(positions[:, 0], positions[:, 1], positions[:, 2],
os[:, 0], os[:, 1], os[:, 2], figure=self.figure)
self.figure.scene.disable_render = False
# Ensure everything fits inside the camera viewport
mlab.get_engine().current_scene.scene.reset_zoom()
return self
示例3: plot
def plot(self, size=(800, 800), fig=None, HPI_ns=False):
"""
Plot sensor helmet and head. ``fig`` is used if provided, otherwise
a new mayavi figure is created with ``size``.
HPI_ns : bool
Add number labels to the HPI points.
"""
if fig is None:
fig = mlab.figure(size=size)
self.mrk.plot_points(fig, scale=1.1e-2, opacity=.5, color=(1, 0, 0))
self.sensors.plot_points(fig, scale=1e-2, color=(0, 0, 1))
self.HPI.plot_points(fig, scale=1e-2, color=(1, .8, 0))
self.headshape.plot_solid(fig, opacity=1., color=(1, 1, 1))
if self.MRI is not None:
self.MRI.plot_solid(fig, opacity=1., color=(.6, .6, .5))
# label marker points
for i, pt in enumerate(self.mrk.pts[:3].T):
x, y, z = pt
self.txt = mlab.text3d(x, y, z, str(i), scale=.01)
if HPI_ns: # label HPI points
for i, pt in enumerate(self.HPI.pts[:3].T):
x, y, z = pt
mlab.text3d(x, y, z, str(i), scale=.01, color=(1, .8, 0))
return fig
示例4: draw_frame
def draw_frame(self, pose, scale=10, label=''):
R, t = pose
scale = self.scale * scale
clr = [RED, GREEN, BLUE]
vecs = R[:, 0], R[:, 1], R[:, 2]
for k in range(3):
mlab.quiver3d(t[0], t[1], t[2], vecs[k][0], vecs[k][1], vecs[k][2],
color=clr[k], mode='arrow', scale_factor=scale)
mlab.text3d(t[0], t[1], t[2], label, scale=scale/5)
示例5: _set_numbering
def _set_numbering(figure, centers, render_numbering=True, numbers_size=None,
numbers_colour='k'):
import mayavi.mlab as mlab
numbers_colour = _parse_colour(numbers_colour)
numbers_size = _parse_marker_size(numbers_size, centers)
if render_numbering:
for k, p in enumerate(centers):
mlab.text3d(p[0], p[1], p[2], str(k), figure=figure,
scale=numbers_size, orient_to_camera=True,
color=numbers_colour, line_width=2)
示例6: draw_feature_node
def draw_feature_node(self):
label_text = []
junc_len = len(self.skel_data.junction_index)
for i in xrange(len(self.skel_data.feature_node_index)):
label_text.append(str(i))
#mlab.figure(self.program_id[0])
pts = mlab.points3d(self.skel_data.feature_node[:junc_len,0], self.skel_data.feature_node[:junc_len,1], self.skel_data.feature_node[:junc_len,2], color=(.7,.0,0.0), scale_factor=.135, resolution=20)
mlab.points3d(self.skel_data.feature_node[junc_len:,0], self.skel_data.feature_node[junc_len:,1], self.skel_data.feature_node[junc_len:,2], color=(.0,.0,0.7), scale_factor=.1, resolution=20)
for i in xrange(len(label_text)):
mlab.text3d(self.skel_data.feature_node[i,0], self.skel_data.feature_node[i,1], self.skel_data.feature_node[i,2], label_text[i], scale=.15)
示例7: _plot_axes
def _plot_axes(lattice, color=(1, 0, 0)):
lat = np.transpose([x/np.linalg.norm(x) for x in lattice.T])
mlab.quiver3d([0, 0, 0],
[0, 0, 0],
[0, 0, 0],
lat[0],
lat[1],
lat[2],
color=color,
line_width=3,
scale_factor=1)
for c, v in zip(('a','b','c'), (lat * 1.3).T):
mlab.text3d(v[0]+0.15, v[1], v[2], c, color=color, scale=0.3)
示例8: test_text3d
def test_text3d(self):
"""Test if Text3D shows"""
# the points3d is there to provide data for
# attaching the text3d module. Opacity is set to
# zero so that the image should only show
# the text3d and we look for the pixels
mlab.points3d(0., 0., 0., opacity=0.)
self.addCleanup(self.mlab_close_all)
mlab.text3d(0., 0., 0., "X")
mlab.savefig(self.filename)
self.check()
示例9: mayaplot
def mayaplot(xyznamearray):
x = xyznamearray[1]
y = xyznamearray[2]
z = xyznamearray[3]
labels = xyznamearray[0]
s = mlab.points3d(x[0], y[0], z[0], color=(0,1,1), mode='sphere', scale_factor=100)
for i in range(0,26):
mlab.points3d(x[i], y[i], z[i], color=(0,1,1), mode='sphere', scale_factor=5000, opacity=0.5)
mlab.text3d(x[i], y[i], z[i], labels[i], scale=5000)
axes = mlab.axes(s, extent = (-220000,220000, -220000,220000, -220000,220000), nb_labels=3)
示例10: drawLabels
def drawLabels(figure, handle, vol, bbox):
"""
Draw all labels in the volume 'vol' at the center of mass position of the object
into the figure 'figure'. Therefore, the bounding box 'bbox' coordinates of 'vol'
must be specified.
"""
# find all labels
labels = np.unique(vol)
if(labels[0] == 0):
# remove background label
labels = labels[1:]
#write the cell label as text
for i in labels:
com = handle["features"][str(i)]["com"][:]
mlab.text3d(com[2]-bbox[2]+1,com[1]-bbox[1]+1,com[0]-bbox[0]+1, str(i), color=(1,1,1), figure=figure)
示例11: nodes_gen
def nodes_gen(self):
#assumes that all LH nodes start with L. This is not ideal.
nodesource_lh = mlab.pipeline.scalar_scatter(
self.ds.lab_pos[self.ds.lhnodes,0],
self.ds.lab_pos[self.ds.lhnodes,1],
self.ds.lab_pos[self.ds.lhnodes,2],
figure=self.scene.mayavi_scene)
self.nodes_lh=mlab.pipeline.glyph(nodesource_lh,
scale_mode='none',scale_factor=3.0,mode='sphere',
figure=self.scene.mayavi_scene)
nodesource_rh=mlab.pipeline.scalar_scatter(
self.ds.lab_pos[self.ds.rhnodes,0],
self.ds.lab_pos[self.ds.rhnodes,1],
self.ds.lab_pos[self.ds.rhnodes,2],
figure=self.scene.mayavi_scene)
self.nodes_rh=mlab.pipeline.glyph(nodesource_rh,
scale_mode='none',scale_factor=3.0,mode='sphere',
figure=self.scene.mayavi_scene)
self.txt = mlab.text3d(0,0,83,'',scale=4.0,color=(.8,.6,.98,),
figure=self.scene.mayavi_scene)
self.txt.actor.actor.pickable=0
for nodes in (self.nodes_lh,self.nodes_rh):
nodes.glyph.color_mode='color_by_scalar'
self.ds.chg_lh_nodemask(); self.ds.chg_rh_nodemask()
self.ds.chg_scalar_colorbar()
#scalar colorbar is tied to lh_surf, but we dont really care if surf switches
#between cracked and uncracked so it is more convenient to set up here
self.draw_nodes()
示例12: nodes_gen
def nodes_gen(self):
#assumes that all LH nodes start with L. This is not ideal.
nodesource_lh = mlab.pipeline.scalar_scatter(
self.ds.lab_pos[self.ds.lhnodes,0],
self.ds.lab_pos[self.ds.lhnodes,1],
self.ds.lab_pos[self.ds.lhnodes,2],
figure=self.scene.mayavi_scene)
self.nodes_lh=mlab.pipeline.glyph(nodesource_lh,
scale_mode='none',scale_factor=3.0,mode='sphere',
figure=self.scene.mayavi_scene)
nodesource_rh=mlab.pipeline.scalar_scatter(
self.ds.lab_pos[self.ds.rhnodes,0],
self.ds.lab_pos[self.ds.rhnodes,1],
self.ds.lab_pos[self.ds.rhnodes,2],
figure=self.scene.mayavi_scene)
self.nodes_rh=mlab.pipeline.glyph(nodesource_rh,
scale_mode='none',scale_factor=3.0,mode='sphere',
figure=self.scene.mayavi_scene)
self.txt = mlab.text3d(0,0,83,'',scale=4.0,color=(.8,.6,.98,),
figure=self.scene.mayavi_scene)
self.txt.actor.actor.pickable=0
for nodes in (self.nodes_lh,self.nodes_rh):
nodes.glyph.color_mode='color_by_scalar'
self.ds.chg_lh_nodemask(); self.ds.chg_rh_nodemask()
self.draw_nodes()
示例13: plot_text
def plot_text(self, label, X, text, size=1):
view = mlab.view()
roll = mlab.roll()
self.figure.scene.disable_render = True
scale = (size, size, size)
mlab_objs = self.plots.get(label)
if mlab_objs != None:
if len(mlab_objs) != len(text):
for obj in mlab_objs:
obj.remove()
self.plots.pop(label)
mlab_objs = self.plots.get(label)
if mlab_objs == None:
text_objs = []
for x, t in zip(X, text):
text_objs.append(mlab.text3d(x[0], x[1], x[2], str(t), scale=scale))
self.plots[label] = text_objs
elif len(mlab_objs) == len(text):
for i, obj in enumerate(mlab_objs):
obj.position = X[i,:]
obj.text = str(text[i])
obj.scale = scale
else:
print "HELP, I shouldn\'t be here!!!!!"
self.figure.scene.disable_render = False
mlab.view(*view)
mlab.roll(roll)
示例14: test_text3d
def test_text3d(self):
""" Test the text3d module.
"""
data = np.random.random((3, 3, 3))
src = mlab.pipeline.scalar_field(data)
t = mlab.text3d(0, 0, 0, 'foo', opacity=0.5, scale=2,
orient_to_camera=False, color=(0, 0, 0),
orientation=(90, 0, 0))
示例15: plot_clusters
def plot_clusters():
points = np.genfromtxt('data.csv', delimiter=',')
means = np.genfromtxt('means.csv', delimiter=',')
points3d(
points[:,0],
points[:,1],
points[:,2],
color=(1,1,1),
mode='2dvertex')
points3d(means[:,0], means[:,1], means[:,2], color=(1,0,0), scale_factor=0.2)
for mean in means:
text3d(
mean[0],
mean[1],
mean[2],
text='({:01.1f}, {:01.1f}, {:01.1f})'.format(mean[0], mean[1], mean[2]),
scale=0.5,
color=(1,1,1))