Reputation: 525
Is there any way to arbitrarily place a colorbar?
Take for instance the following Python code into ParaView's 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
I can make the colorbar horizontal but I can't find a way to modify its placement. See figure below:
Upvotes: 2
Views: 3527
Reputation: 705
First get the scalarbar corresponding to the lookup table (rTDataLUT) and the render view (renderView1) :
scalarbar = GetScalarBar(rTDataLUT, renderView1)
Then set the position of the bottom left corner of the scalarbar with the Position property. This position is expressed as a ratio of the render view size in each direction. Default value should be [0.85, 0.05]. For instance :
scalarbar.Position = [0.85, 0.2]
Finally, update your render view with Render() :
Render(renderView1)
Upvotes: 4