Python ParaView 脚本:颜色条放置

Python scripting for ParaView: Colorbar placement

有什么办法可以任意放置一个colorbar吗?

例如将以下 Python 代码放入 ParaView 的 shell:

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# create a new 'Wavelet'
wavelet1 = Wavelet()

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1229, 814]

# show data in view
wavelet1Display = Show(wavelet1, renderView1)
# trace defaults for the display properties.
wavelet1Display.Representation = 'Outline'
wavelet1Display.ColorArrayName = ['POINTS', '']
wavelet1Display.GlyphType = 'Arrow'
wavelet1Display.ScalarOpacityUnitDistance = 1.7320508075688779
wavelet1Display.Slice = 10

# reset view to fit data
renderView1.ResetCamera()

# set scalar coloring
ColorBy(wavelet1Display, ('POINTS', 'RTData'))

# rescale color and/or opacity maps used to include current data range
wavelet1Display.RescaleTransferFunctionToDataRange(True)

# change representation type
wavelet1Display.SetRepresentationType('Volume')

# get color transfer function/color map for 'RTData'
rTDataLUT = GetColorTransferFunction('RTData')

# get opacity transfer function/opacity map for 'RTData'
rTDataPWF = GetOpacityTransferFunction('RTData')

# show color bar/color legend
wavelet1Display.SetScalarBarVisibility(renderView1, True)

#### saving camera placements for all active views

# current camera placement for renderView1
renderView1.CameraPosition = [0.0, 0.0, 66.92130429902464]
renderView1.CameraParallelScale = 17.320508075688775

我可以使颜色栏水平,但我找不到修改其位置的方法。见下图:

首先获取查找table对应的标量条(rTDataLUT)和渲染视图(renderView1):

scalarbar = GetScalarBar(rTDataLUT, renderView1)

然后用Position属性设置标量条左下角的位置。该位置表示为每个方向上渲染视图大小的比率。默认值应为 [0.85, 0.05]。 例如:

scalarbar.Position = [0.85, 0.2]

最后,使用 Render() 更新渲染视图:

Render(renderView1)