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

# settings
# scaling factor
scale = 0.05

# do something if any data loaded
if GetActiveSource():

    # get display
    dp = GetDisplayProperties()
    
    # get variable currently shown
    myshownvar = dp.ColorArrayName[1]  # 
    
    # check if variable selected (no solid coloring)
    if myshownvar:
    
        # get color transfer function/color map for variable
        tLUT = GetColorTransferFunction(myshownvar)
    
        # get current legend setting
        val = tLUT.GetPropertyValue('RGBPoints')
        legendmin = val[0]
        legendmax = val[-4]
    
        delta = (legendmax - legendmin) * scale
    
        legendmin = legendmin + delta
        #legendmax = legendmax - delta
    
        # Rescale transfer function
        tLUT.RescaleTransferFunction(legendmin, legendmax)
    
    
        # get opacity transfer function/opacity map for variable
        tPWF = GetOpacityTransferFunction(myshownvar)
        # Rescale transfer function identical to color
        tPWF.RescaleTransferFunction(legendmin, legendmax)
    
        RenderAllViews()

#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

