• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mlab.text3d函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mayavi.mlab.text3d函数的典型用法代码示例。如果您正苦于以下问题:Python text3d函数的具体用法?Python text3d怎么用?Python text3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了text3d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:JaimeIvanCervantes,项目名称:hytra,代码行数:29,代码来源:visCell.py


示例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
开发者ID:Loubnar,项目名称:menpo3d,代码行数:26,代码来源:viewmayavi.py


示例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
开发者ID:teonbrooks,项目名称:Eelbrain,代码行数:32,代码来源:coreg.py


示例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)
开发者ID:JCostas-AIMEN,项目名称:etna,代码行数:9,代码来源:mlabplot.py


示例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)
开发者ID:HaoyangWang,项目名称:menpo3d,代码行数:10,代码来源:viewmayavi.py


示例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)
开发者ID:bo-wu,项目名称:skel_corres,代码行数:10,代码来源:display_skeleton.py


示例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)
开发者ID:mgtekns,项目名称:cogue,代码行数:14,代码来源:mayavi2.py


示例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()
开发者ID:PeterZhouSZ,项目名称:mayavi,代码行数:14,代码来源:test_text3d.py


示例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)
开发者ID:ArunGupta25,项目名称:astroproject,代码行数:15,代码来源:satellitefunc.py


示例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)
开发者ID:JaimeIvanCervantes,项目名称:hytra,代码行数:16,代码来源:visCell.py


示例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()
开发者ID:aestrivex,项目名称:cvu,代码行数:33,代码来源:dataview.py


示例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()
开发者ID:mick-d,项目名称:cvu,代码行数:29,代码来源:dataview.py


示例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)
开发者ID:PrasadBabarendaGamage,项目名称:morphic,代码行数:31,代码来源:viewer.py


示例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))
开发者ID:dmsurti,项目名称:mayavi,代码行数:8,代码来源:test_mlab_integration.py


示例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))
开发者ID:ashvant,项目名称:clusterer,代码行数:18,代码来源:plot_clusters.py


示例16: _show_labels

    def _show_labels(self, show):
        _toggle_mlab_render(self, False)
        while self.text3d:
            text = self.text3d.pop()
            text.remove()

        if show and len(self.src.data.points) > 0:
            fig = self.scene.mayavi_scene
            if self._view == 'arrow':  # for axes
                x, y, z = self.src.data.points[0]
                self.text3d.append(text3d(
                    x, y, z, self.name, scale=self.label_scale,
                    color=self.color, figure=fig))
            else:
                for i, (x, y, z) in enumerate(np.array(self.src.data.points)):
                    self.text3d.append(text3d(
                        x, y, z, ' %i' % i, scale=self.label_scale,
                        color=self.color, figure=fig))
        _toggle_mlab_render(self, True)
开发者ID:jdammers,项目名称:mne-python,代码行数:19,代码来源:_viewer.py


示例17: _plot_coordinate_transforms

def _plot_coordinate_transforms(*Targs, **kwargs):
    tag = kwargs.get('tag', '')
    origin = kwargs.get('origin', True)
    scale = kwargs.get('scale', 0.1)
    x, y, z, u, v, w, scalars = quiver_args_from_transforms(*Targs,
                                                            origin=origin)
    pts = mlab.quiver3d(x, y, z, u, v, w,
                        scalars=scalars,
                        line_width=40.0 * scale,
                        scale_factor=scale)
    pts.glyph.color_mode = 'color_by_scalar'
    for i, (xi, yi, zi) in enumerate(zip(x, y, z)):
        if not (i % 3):
            txt = str(i / 3 - 1)
            if i == 0:
                txt = 'O'
            txt = '%s%s' % (tag, txt)
            mlab.text3d(xi, yi, zi, text=txt, scale=0.6 * scale)
    mlab.gcf().scene.background = (1, 1, 1)
    return pts
开发者ID:iEarthos,项目名称:mutual_localization,代码行数:20,代码来源:mayaviutils.py


示例18: plot_labels

def plot_labels(labels, lattice=None, coords_are_cartesian=False, figure=None, **kwargs):  # pragma: no cover
    """
    Adds labels to a mayavi_ figure.

    Args:
        labels: dict containing the label as a key and the coordinates as value.
        lattice: |Lattice| object used to convert from reciprocal to cartesian coordinates
        coords_are_cartesian: Set to True if you are providing.
            coordinates in cartesian coordinates. Defaults to False.
            Requires lattice if False.
        figure: mayavi figure, None to plot on the curretn figure
        kwargs: kwargs passed to the mayavi function `text3d`. Color defaults to blue and size to 25.

    Returns: mayavi figure
    """
    figure, mlab = get_fig_mlab(figure=figure)

    #if "color" not in kwargs:
    #    kwargs["color"] = "b"
    #if "size" not in kwargs:
    #    kwargs["size"] = 25
    #if "width" not in kwargs:
    #    kwargs["width"] = 0.8
    if "scale" not in kwargs:
        kwargs["scale"] = 0.1

    for k, coords in labels.items():
        label = k
        if k.startswith("\\") or k.find("_") != -1:
            label = "$" + k + "$"
        off = 0.01
        if coords_are_cartesian:
            coords = np.array(coords)
        else:
            if lattice is None:
                raise ValueError("coords_are_cartesian False requires the lattice")
            coords = lattice.get_cartesian_coords(coords)
        x, y, z = coords + off
        mlab.text3d(x, y, z, label, figure=figure, **kwargs)

    return figure
开发者ID:gmatteo,项目名称:abipy,代码行数:41,代码来源:mvtk.py


示例19: _plot_axes

 def _plot_axes(self, color=(1, 0, 0)):
     shortest = min(np.linalg.norm(self._lattice, axis=1))
     lat = np.array([x / np.linalg.norm(x) for x in self._lattice])
     lat *= shortest
     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)
 
     scale = shortest / 8
     for c, v in zip(('a','b','c'), lat * (1 + scale / 2)):
         x, y, z = v
         x += scale / 2
         y -= scale / 4
         z -= scale / 4
         mlab.text3d(x, y, z, c, color=color, scale=scale)
开发者ID:atztogo,项目名称:cogue,代码行数:21,代码来源:bz.py


示例20: draw_didi_boxes3d

def draw_didi_boxes3d(fig, boxes3d, is_number=False, color=(1,1,1), line_width=1):

    if boxes3d.shape==(8,3): boxes3d=boxes3d.reshape(1,8,3)

    num = len(boxes3d)
    for n in range(num):
        b = boxes3d[n]

        if is_number:
            mlab.text3d(b[0,0], b[0,1], b[0,2], '%d'%n, scale=(1, 1, 1), color=color, figure=fig)
        for k in range(0,4):

            #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html
            i,j=k,(k+1)%4
            mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig)

            i,j=k+4,(k+1)%4 + 4
            mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig)

            i,j=k,k+4
            mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig)
开发者ID:Bruslan,项目名称:MV3D-1,代码行数:21,代码来源:show_lidar.py



注:本文中的mayavi.mlab.text3d函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mlab.title函数代码示例发布时间:2022-05-27
下一篇:
Python mlab.text函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap