simple.color Module

paraview.simple.color.AssignFieldToColorPreset(array_name, preset_name, range_override=None)[source]

Assign a lookup table to an array by lookup table name.

Example usage:

AssignFieldToPreset("Temperature", "Cool to Warm")
Parameters:
  • array_name (str) – The array name for which we want to bind a given color preset.

  • preset_name (str) – The name for the color preset.

  • range_override (2-element tuple or list of floats) – The range to use instead of the range of the array.

Returns:

True on success, False otherwise.

Return type:

bool

paraview.simple.color.CreateLookupTable(**params)[source]

Create and return a lookup table.

Parameters:

params – A variadic list of key=value pairs giving values of specific named properties of the lookup table.

Returns:

Lookup table

Return type:

Lookup table proxy

paraview.simple.color.CreatePiecewiseFunction(**params)[source]

Create and return a piecewise function.

Parameters:

params – A variadic list of key=value pairs giving values of specific named properties of the opacity function.

Returns:

Piecewise opacity function

Return type:

Opacity functon proxy

paraview.simple.color.ExportTransferFunction(colortransferfunction, opacitytransferfunction, tfname, filename, location=16)[source]

Export transfer function to a file. The file will be saved in the new JSON format.

Parameters:
  • colortransferfunction (Color transfer function proxy.) – The color transfer function to export.

  • opacitytransferfunction (Opacity transfer function proxy.) – The opacity transfer functon to export, if provided. can be None.

  • tfname (str) – The name that will be given to the transfer function preset if imported back into ParaView.

  • filename (str) – Path to file where exported transfer function should be saved.

  • location (vtkPVServer.ServerFlags enum value) – Where the statefile should be saved, e.g., pass vtkPVSession.CLIENT if the statefile is located on the client system (default value), pass in vtkPVSession.SERVERS if on the server. Optional, defaults to vtkPVSession.CLIENT.

Returns:

True on success, False otherwise.

paraview.simple.color.GenerateRGBPoints(preset_name=None, range_min=None, range_max=None)[source]

Create and return a list of RGB points by using the provided arguments. The returned RGB points are intended to be used by transfer functions.

This function is used by Python state files so that they do not have to write out every single RGB point for a transfer function if those RGB points can be easily re-created.

Parameters:
  • preset_name (str or None) – A preset name to apply, if any.

  • range_min (float or None) – The minimum value for rescaling the RGBPoints range

  • range_min – The maximum value for rescaling the RGBPoints range

Returns:

A list of RGBPoints which can be used in transfer functions

Return type:

list[float]

NOTE: this function might be used by old state files. As such, we must not break backward-compatibility with it.

paraview.simple.color.GetBlockColorTransferFunction(selector, arrayname, representation=None, separate=False, **params)[source]

Get the color transfer function used to map a data array with the given name to colors in the blocks referred to by a selector expresson.

Parameters:
  • selector (str) – Selector expression used to select blocks from whom the color transfer should be retrieved.

  • arrayname (str) – Name of the array whose color transfer function is requested.

  • representation (Representation proxy.) – Used to modify the array name when using a separate color transfer function. Optional, defaults to the active proxy.

  • separate (bool) – If True, used to recover the separate color transfer function even if it is not used currently by the representation. Optional, defaults to False.

Returns:

This may create a new color transfer function if none exists, or return an existing one if found.

Return type:

Color transfer function proxy

paraview.simple.color.GetColorTransferFunction(arrayname, representation=None, separate=False, **params)[source]

Get the color transfer function used to map a data array with the given name to colors.

Parameters:
  • arrayname (str) – Name of the array whose color transfer function is requested.

  • representation (Representation proxy.) – Used to modify the array name when using a separate color transfer function. Optional, defaults to the active proxy.

  • separate (bool) – If True, used to recover the separate color transfer function even if it is not used currently by the representation. Optional, defaults to False.

Returns:

This may create a new color transfer function if none exists, or return an existing one if found.

Return type:

Color transfer function proxy

paraview.simple.color.GetOpacityTransferFunction(arrayname, representation=None, separate=False, **params)[source]

Get the opacity transfer function used to map a data array with the given name to opacities in the blocks referred to by a selector expresson.

Parameters:
  • arrayname (str) – Name of the array whose opacity transfer function is requested.

  • representation (Representation proxy.) – Used to modify the array name when using a separate opacity transfer function. Optional, defaults to the active representation.

  • separate (bool) – If True, used to recover the separate opacity transfer function even if it is not used currently by the representation. Optional, defaults to False.

Returns:

This may create a new opacity transfer function if none exists, or return an existing one if found.

Return type:

Opacity transfer function proxy

paraview.simple.color.GetTransferFunction2D(arrayname, array2name=None, representation=None, separate=False, **params)[source]

Get the 2D color transfer function used to map a data array with the given name to colors.

Parameters:
  • arrayname (str) – Name of the first array whose color transfer function is requested.

  • array2name (str) – Name of the second array whose color transfer function is requested.

  • representation (Representation proxy.) – Used to modify the array name when using a separate color transfer function. Optional, defaults to the active representation.

  • separate (bool) – If True, used to recover the separate color transfer function even if it is not used currently by the representation. Optional, defaults to False.

Returns:

This may create a new 2D color transfer function if none exists, or return an existing one if found.

Return type:

2D color transfer function proxy

paraview.simple.color.ImportPresets(filename, location=16)[source]

Import presets from a file. The file can be in the legacy color map XML format or in the new JSON format.

Parameters:
  • filename (str) – Path of the file containing the presets.

  • location (vtkPVServer.ServerFlags enum value) – Where the statefile should be save, e.g., pass vtkPVSession.CLIENT if the statefile is located on the client system (default value), pass in vtkPVSession.SERVERS if on the server. Optional, defaults to vtkPVSession.CLIENT.

Returns:

True on success, False otherwise.

paraview.simple.color.ListColorPresetNames()[source]

Returns a list containing the currently available color transfer function preset names.

Returns:

List of currently available transfer function preset names.

Return type:

List of str

paraview.simple.color.LoadPalette(paletteName)[source]

Load a color palette to override the default foreground and background colors used by ParaView views. The current global palette’s colors are set to the colors in the loaded palette.

Parameters:

paletteName (str) – Name of the palette to load from this list: ‘WarmGrayBackground’, ‘DarkGrayBackground’, ‘NeutralGrayBackground’, ‘LightGrayBackground’, ‘WhiteBackground’, ‘BlackBackground’, ‘GradientBackground’.