首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在两个不同的场景中作图

在两个不同的场景中作图
EN

Stack Overflow用户
提问于 2015-05-29 09:49:18
回答 1查看 529关注 0票数 0

我试图在mayavi中的两个不同场景中同时绘制两个图像平面部件。但这两架飞机都出现在第一幕中。有谁知道怎么解决这个问题吗?

下面是我的代码示例:

代码语言:javascript
复制
import numpy as np
from mayavi import mlab
from mayavi.mlab import axes, outline
from traitsui.api import View, Item, Group, HGroup
from mayavi.core.pipeline_base import PipelineBase
from mayavi.core.ui.api import MayaviScene, SceneEditor, MlabSceneModel

class myclass():
  p='somedata[20][20][20]' #I can't give you the data here because it's too big
  scene = Instance(MlabSceneModel, ())        
  sx = Instance(MlabSceneModel, ())
  plot = Instance(PipelineBase)

  def function(self):
    self.src = mlab.pipeline.scalar_field(self.p)
    self.plot2 = self.scene.mlab.pipeline.image_plane_widget(self.src,         
                            plane_orientation='x_axes',             
                            slice_index=0,
                            #vmin=0, vmax=140,
                            colormap='hot')

    self.sx.scene.parallel_projection = True
    side_src = self.plot.ipw._get_reslice_output() #gets the data for the 2d planes
    self.ipw = self.sx.mlab.pipeline.image_plane_widget(     #creates the 2d views
                            side_src,
                            plane_orientation='z_axes',
                            #vmin=self.data.min(),
                            #vmax=self.data.max(),
                            #figure=self.sx.mayavi_scene,
                            name='Cut view X',
                            colormap='hot',
                            )

    mlab.colorbar(title='Wert', orientation='vertical', nb_labels=5, label_fmt='%.3f')            #adds a colorbar at the left side of the screen
    mlab.view(azimuth=50,elevation=50,distance=80,focalpoint=(10,15,10))      #defines the starting view of the camera
    mlab.roll(110)
    self.scene.scene_editor.background = (0, 0, 0)
    view = View(HGroup(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
                                  height=400, width=500, show_label=False),
                       Item('sx',editor=SceneEditor(scene_class=MayaviScene),
                                  height=400, width=500, show_label=False),),
                resizable=True,
                )

myclass()

我无法在网络上找到解决方案,有多个场景的例子,但我不知道为什么它在那里工作,而不是在我的代码中。任何帮助都会很好。

当我尝试在image_plane_widget中使用image_plane_widget kwarg时,如下所示

代码语言:javascript
复制
self.plot = mlab.pipeline.image_plane_widget(self.src,         
                            plane_orientation='x_axes',             
                            slice_index=0,
                            #vmin=0, vmax=140,
                            figure=self.sx,
                            colormap='hot')

它返回以下错误:

TraitError: ImagePlaneWidgetFactory实例的“图形”特征必须是场景或无,但值是指定的。

EN

回答 1

Stack Overflow用户

发布于 2015-05-29 22:25:26

要指定管道调用中指向的场景,包括figure、kwarg和类似的内容,例如mlab.pipeline.image_plane_widget(*args, figure=self.scene)。否则,如果没有指定figure,管道调用将转到mlab.gcf(),这通常是最后创建的数字。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30526429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档