我有3D标量和矢量数据,我将其与流线(mlab.pipeline.streamline
)和图像平面(mlab.pipeline.image_plane_widget
)一起绘制。这通常是有效的,但是偶尔(即在一些数据集上)两种类型的图形变得不对齐 - 即使数据形状都完全相同。
好榜样:
错误示例:
这始终是范例:流线的边界框沿着单轴延伸......没有任何设置在变化!
例如,我有一个标量字段scal
,其尺寸与向量字段vect
相同:
mlab.options.offscreen = True
# Initialized figure
fig = mlab.figure(size=[1000,1000])
extent = [0,1,0,1,0,1]
shape = np.shape(scal)
x,y,z = np.mgrid[ 0:1.0:1j*shape[0] , 0:1.0:1j*shape[1] , 0:1.0:1j*shape[2] ]
# Draw vector field
u,v,w = vect[...,0], vect[...,1], vect[...,2]
vect_field = mlab.pipeline.vector_field(x,y,z, u,v,w)
streams = mlab.pipeline.streamline(vect_field, figure=fig, extent=extent, reset_zoom=False, \
seedtype='plane', seed_scale=2.0, colormap='Greens')
streams.stream_tracer.integration_direction = 'both'
mlab.outline()
seed = streams.seed.widget
seed.set( normal=[0.0,0.0,1.0] )
seed.set( center=[0.5,0.5,0.5] )
seed.set( resolution=SEED_RESOLUTION )
seed.enabled = False
# Draw scalar field
scal = np.log10(scal)
scal_field = mlab.pipeline.scalar_field(x,y,z, scal)
midz = np.int(np.floor(shape[2]*0.5))
plane1 = mlab.pipeline.image_plane_widget(scal_field, figure=fig, plane_orientation='z_axes', \
slice_index=midz, opacity=0.1, transparent=True, \
extent=extent, reset_zoom=False )
plane2 = mlab.pipeline.image_plane_widget(scal_field, figure=fig, plane_orientation='x_axes', \
slice_index=0, opacity=0.1, \
extent=extent, reset_zoom=False )
mlab.text3d(0.5,0.5,1.07, 'Time = %04.0f' % time, scale=0.05, figure=fig)
mlab.colorbar()
mlab.view(35, 75, 3.0, focalpoint=[0.5,0.5,0.4])
可以在此处找到用于重现问题的数据代码:
https://drive.google.com/folderview?id=0B4FXIXq2e3y4UGMyREFaWnV2Mjg&usp=sharing
答案 0 :(得分:0)
问题在于image_plane_widget
根本不接受'范围'参数。从image_plane_widget
和streamline
中删除“范围”参数会使对象匹配。