| name | paraview |
| description | ParaView scientific visualization for volume data and meshes. Use this skill when Claude needs to: (1) Visualize 3D volume data (CT, MRI, scientific simulations), (2) Create isosurfaces, slices, volume renderings, (3) Visualize vector fields with streamlines/glyphs, (4) Generate publication-quality screenshots, (5) Work with VTK, EXODUS, RAW, or other scientific data formats
|
ParaView Scientific Visualization
API Documentation Version: 5.12.1
This skill's API reference is based on ParaView 5.12.1. If you're using a different version, some functions may not be available or behave differently.
Check version: from paraview.simple import GetParaViewVersion; print(GetParaViewVersion())
Rules
- Never open a GUI — always use
pvpython for headless batch execution
- Use
from paraview.simple import * at the top of every script
- Always call
UpdatePipeline() after loading EXODUS/IOSS files before accessing data information
- Always call
ResetCamera(renderView) before SaveScreenshot to ensure all data is in frame
- Prerequisites assumed:
pvpython available on PATH (or $PARAVIEW_HOME/bin/pvpython)
- For visual matching tasks, iterate with: screenshot → assess → adjust → re-screenshot
- After taking a screenshot, use the Read tool to view the image and verify correctness
- Use
pvpython (not python) to run ParaView scripts
- Optimize color/opacity mapping first; change camera only when well-motivated
Workflow Decision Tree
Interactive Visualization (GUI)
Use the Opening ParaView GUI section to launch ParaView with pvserver
Batch Processing (Script Generation)
- Generate a ParaView Python script following examples
- Execute with pvpython:
$PARAVIEW_HOME/bin/pvpython script.py
Opening ParaView GUI
When the user says "Open ParaView GUI" or requests to launch ParaView:
-
Start pvserver first:
$PARAVIEW_HOME/bin/pvserver --server-port=11111 --multi-clients &
-
Launch ParaView GUI with auto-connect:
$PARAVIEW_HOME/bin/paraview --server-url=cs://localhost:11111 &
Canonical Script Template
from paraview.simple import *
INPUT_FILE = '/path/to/input.vtk'
OUTPUT_FILE = '/path/to/screenshot.png'
IMAGE_SIZE = [1920, 1080]
data = LegacyVTKReader(FileNames=[INPUT_FILE])
bounds = data.GetDataInformation().GetBounds()
center = [(bounds[0]+bounds[1])/2, (bounds[2]+bounds[3])/2, (bounds[4]+bounds[5])/2]
renderView = CreateView('RenderView')
renderView.ViewSize = IMAGE_SIZE
renderView.Background = [0.1, 0.1, 0.15]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
display = Show(data, renderView)
ResetCamera(renderView)
SaveScreenshot(OUTPUT_FILE, renderView,
ImageResolution=IMAGE_SIZE,
OverrideColorPalette='WhiteBackground')
Core Operations
Loading Data
from paraview.simple import *
data = OpenDataFile('path/to/file.vtk')
data = LegacyVTKReader(FileNames=['path/to/file.vtk'])
data = IOSSReader(FileName=['path/to/file.ex2'])
data.UpdatePipeline()
reader = ImageReader(FileNames=['path/to/file.raw'])
reader.DataExtent = [0, 255, 0, 255, 0, 255]
reader.DataScalarType = 'unsigned char'
reader.DataByteOrder = 'LittleEndian'
reader.FileDimensionality = 3
reader.NumberOfScalarComponents = 1
reader.UpdatePipeline()
Get Data Information
source = GetActiveSource()
bounds = source.GetDataInformation().GetBounds()
pd = source.PointData
min_val, max_val = pd.GetArray('fieldName').GetRange()
center = [(bounds[0]+bounds[1])/2, (bounds[2]+bounds[3])/2, (bounds[4]+bounds[5])/2]
Volume Rendering
source = GetActiveSource()
pd = source.PointData
min_val, max_val = pd.GetArray(0).GetRange()
lut = GetColorTransferFunction('fieldName')
lut.RGBPoints = [min_val, 0.0, 0.0, 0.75,
(min_val + max_val)/2, 0.75, 0.75, 0.75,
max_val, 0.75, 0.0, 0.0]
pwf = GetOpacityTransferFunction('fieldName')
pwf.Points = [min_val, 0.0, 0.5, 0.0,
(min_val + max_val)/2, 0.5, 0.5, 0.0,
max_val, 1.0, 0.5, 0.0]
display = Show(source, renderView)
display.Representation = 'Volume'
display.ColorArrayName = ['POINTS', 'fieldName']
display.LookupTable = lut
display.ScalarOpacityFunction = pwf
Isosurfaces (Contours)
contour = Contour(Input=source)
contour.ContourBy = ['POINTS', 'fieldName']
contour.Isosurfaces = [0.5]
contour.PointMergeMethod = 'Uniform Binning'
Show(contour, renderView)
Multiple Contour Lines (sampled range)
import numpy as np
contour_values = np.linspace(min_val, max_val, 8).tolist()
contour = Contour(Input=source)
contour.ContourBy = ['POINTS', 'fieldName']
contour.Isosurfaces = contour_values
display = Show(contour, renderView)
display.Opacity = 0.6
Slices
slice_filter = Slice(Input=source)
slice_filter.SliceType = 'Plane'
slice_filter.SliceType.Origin = [x, y, z]
slice_filter.SliceType.Normal = [0, 0, 1]
Show(slice_filter, renderView)
Clip
clip = Clip(Input=source)
clip.ClipType = 'Plane'
clip.ClipType.Origin = [0.0, 0.0, 0.0]
clip.ClipType.Normal = [1.0, 0.0, 0.0]
clip.InsideOut = False
Show(clip, renderView)
Threshold
thresh = Threshold(Input=source)
thresh.Scalars = ['POINTS', 'fieldName']
thresh.ThresholdRange = [min_value, max_value]
Show(thresh, renderView)
Streamlines
bounds = source.GetDataInformation().GetBounds()
center = [(bounds[0]+bounds[1])/2, (bounds[2]+bounds[3])/2, (bounds[4]+bounds[5])/2]
tracer = StreamTracer(Input=source, SeedType='Point Cloud')
tracer.Vectors = ['POINTS', 'vectorField']
tracer.IntegrationDirection = 'BOTH'
tracer.MaximumStreamlineLength = 50.0
tracer.SeedType.Center = center
tracer.SeedType.NumberOfPoints = 100
tracer.SeedType.Radius = 1.0
tube = Tube(Input=tracer)
tube.Radius = 0.1
tubeDisplay = Show(tube, renderView)
ColorBy(tubeDisplay, ('POINTS', 'scalarField'))
Glyphs
glyph = Glyph(Input=source, GlyphType='Arrow')
glyph.OrientationArray = ['POINTS', 'vectorField']
glyph.ScaleArray = ['POINTS', 'vectorField']
glyph.ScaleFactor = 0.05
glyph.MaximumNumberOfSamplePoints = 5000
glyphDisplay = Show(glyph, renderView)
ColorBy(glyphDisplay, ('POINTS', 'vectorField'))
Warp By Vector
warp = WarpByVector(Input=source)
warp.Vectors = ['POINTS', 'displacementField']
warp.ScaleFactor = 1.0
Show(warp, renderView)
Calculator (Derived Field)
calc = Calculator(Input=source)
calc.ResultArrayName = 'velocity_mag'
calc.Function = 'sqrt(velocity_X^2 + velocity_Y^2 + velocity_Z^2)'
calc.AttributeType = 'Point Data'
Show(calc, renderView)
Transform (Translate / Rotate / Scale)
t = Transform(Input=source)
t.Transform = 'Transform'
t.Transform.Translate = [dx, dy, dz]
t.Transform.Rotate = [rx, ry, rz]
t.Transform.Scale = [sx, sy, sz]
Show(t, renderView)
Gradient & Field Analysis
grad = GradientOfUnstructuredDataSet(Input=source)
grad.SelectInputScalars = ['POINTS', 'pressure']
grad.ComputeVorticity = True
grad.ComputeDivergence = True
grad.ComputeQCriterion = True
Show(grad, renderView)
conn = ConnectivityFilter(Input=source)
Show(conn, renderView)
Delaunay Triangulation (Points to Surface)
delaunay = Delaunay3D(Input=points)
delaunay.Alpha = 0.0
delaunay.Offset = 2.0
delaunay.Tolerance = 0.001
display = Show(delaunay, renderView)
display.SetRepresentationType('Wireframe')
Plot Over Line (Line Probe)
plot = PlotOverLine(Input=source)
plot.Point1 = [x1, y1, z1]
plot.Point2 = [x2, y2, z2]
plot.Resolution = 100
chartView = CreateView('XYChartView')
Show(plot, chartView, 'XYChartRepresentation')
AssignViewToLayout(view=chartView)
Render View Setup
renderView = CreateView('RenderView')
renderView.ViewSize = [1920, 1080]
renderView.Background = [0.1, 0.1, 0.15]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
renderView.CameraPosition = [3.86, 3.86, 3.86]
renderView.CameraViewUp = [-0.408, 0.816, -0.408]
renderView.CameraPosition = [center[0] - 1.5*max_dim, center[1], center[2]]
renderView.CameraFocalPoint = center
renderView.CameraViewUp = [0.0, 0.0, 1.0]
ResetCamera(renderView)
SaveScreenshot('output.png', renderView, ImageResolution=[1920, 1080],
OverrideColorPalette='WhiteBackground')
Display Properties
display = GetDisplayProperties(source, renderView)
display.SetRepresentationType('Surface')
ColorBy(display, ('POINTS', 'fieldName'))
display.RescaleTransferFunctionToDataRange(True)
ColorBy(display, None)
display.DiffuseColor = [1.0, 0.0, 0.0]
display.Opacity = 0.5
display.Visibility = 1
Color Map Presets
from paraview.simple import ApplyPreset
lut = GetColorTransferFunction('fieldName')
ApplyPreset(lut, 'Cool to Warm', True)
Scalar Bar (Color Legend)
lut = GetColorTransferFunction('fieldName')
colorBar = GetScalarBar(lut, renderView)
colorBar.Title = 'Field Name'
colorBar.ComponentTitle = ''
colorBar.Visibility = 1
colorBar.ScalarBarLength = 0.3
Complete Example Scripts
Volume Rendering
from paraview.simple import *
data = LegacyVTKReader(FileNames=['/path/to/volume.vtk'])
source = GetActiveSource()
pd = source.PointData
min_val, max_val = pd.GetArray(0).GetRange()
lut = GetColorTransferFunction('var0')
lut.RGBPoints = [min_val, 0.0, 0.0, 0.75,
(min_val + max_val)/2, 0.75, 0.75, 0.75,
max_val, 0.75, 0.0, 0.0]
pwf = GetOpacityTransferFunction('var0')
pwf.Points = [min_val, 0.0, 0.5, 0.0,
(min_val + max_val)/2, 0.5, 0.5, 0.0,
max_val, 1.0, 0.5, 0.0]
renderView = CreateView('RenderView')
renderView.ViewSize = [1920, 1080]
renderView.CameraPosition = [3.86, 3.86, 3.86]
renderView.CameraViewUp = [-0.408, 0.816, -0.408]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
display = Show(data, renderView)
display.Representation = 'Volume'
display.ColorArrayName = ['POINTS', 'var0']
display.LookupTable = lut
display.ScalarOpacityFunction = pwf
ResetCamera(renderView)
SaveScreenshot('/path/to/dvr.png', renderView, ImageResolution=[1920, 1080])
Streamlines with Tubes
from paraview.simple import *
data = IOSSReader(FileName=['/path/to/disk.ex2'])
data.UpdatePipeline()
bounds = data.GetDataInformation().GetBounds()
center = [(bounds[0]+bounds[1])/2, (bounds[2]+bounds[3])/2, (bounds[4]+bounds[5])/2]
max_dim = max(bounds[1]-bounds[0], bounds[3]-bounds[2], bounds[5]-bounds[4])
tracer = StreamTracer(Input=data, SeedType='Point Cloud')
tracer.Vectors = ['POINTS', 'V']
tracer.MaximumStreamlineLength = 20.0
tracer.SeedType.Center = center
tracer.SeedType.Radius = 2.0
glyph = Glyph(Input=tracer, GlyphType='Cone')
glyph.OrientationArray = ['POINTS', 'V']
glyph.ScaleArray = ['POINTS', 'V']
glyph.ScaleFactor = 0.06
tube = Tube(Input=tracer)
tube.Radius = 0.075
renderView = CreateView('RenderView')
renderView.ViewSize = [1920, 1080]
renderView.CameraPosition = [center[0] - 1.5*max_dim, center[1], center[2]]
renderView.CameraFocalPoint = center
renderView.CameraViewUp = [0.0, 0.0, 1.0]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
tubeDisplay = Show(tube, renderView)
glyphDisplay = Show(glyph, renderView)
ColorBy(tubeDisplay, ('POINTS', 'Temp'))
ColorBy(glyphDisplay, ('POINTS', 'Temp'))
tubeDisplay.RescaleTransferFunctionToDataRange(True)
glyphDisplay.RescaleTransferFunctionToDataRange(True)
ResetCamera(renderView)
SaveScreenshot('/path/to/streamlines.png', renderView, ImageResolution=[1920, 1080])
RAW Volume File
from paraview.simple import *
raw_file = '/path/to/tooth_103x94x161_uint8.raw'
reader = ImageReader(FileNames=[raw_file])
reader.DataScalarType = 'unsigned char'
reader.DataByteOrder = 'LittleEndian'
reader.DataExtent = [0, 102, 0, 93, 0, 160]
reader.FileDimensionality = 3
reader.NumberOfScalarComponents = 1
reader.UpdatePipeline()
Color Map from JSON File
from paraview.simple import *
data = LegacyVTKReader(FileNames=['/path/to/volume.vtk'])
renderView = CreateView('RenderView')
renderView.ViewSize = [1920, 1080]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
display = Show(data, renderView)
display.Representation = 'Volume'
display.ColorArrayName = ['POINTS', 'fieldName']
import json
with open('/path/to/colormap.json') as f:
cm = json.load(f)[0]
lut = GetColorTransferFunction('fieldName')
lut.RGBPoints = cm['RGBPoints']
if 'Points' in cm:
pwf = GetOpacityTransferFunction('fieldName')
pwf.Points = cm['Points']
display.ScalarOpacityFunction = pwf
display.LookupTable = lut
ResetCamera(renderView)
SaveScreenshot('/path/to/output.png', renderView, ImageResolution=[1920, 1080])
Export Data
from paraview.simple import *
data = LegacyVTKReader(FileNames=['/path/to/input.vtk'])
contour = Contour(Input=data)
contour.ContourBy = ['POINTS', 'fieldName']
contour.Isosurfaces = [0.5]
SaveData('/path/to/output.stl', proxy=contour)
SaveData('/path/to/output.csv', proxy=data)
SaveData('/path/to/output.vtk', proxy=data, DataMode='Binary')
Save Animation (Time Series)
from paraview.simple import *
data = OpenDataFile('/path/to/timeseries.pvd')
renderView = CreateView('RenderView')
renderView.ViewSize = [1920, 1080]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
display = Show(data, renderView)
ColorBy(display, ('POINTS', 'fieldName'))
display.RescaleTransferFunctionToDataRange(True)
ResetCamera(renderView)
scene = GetAnimationScene()
scene.PlayMode = 'Snap To TimeSteps'
SaveAnimation('/path/to/animation.png', renderView,
ImageResolution=[1920, 1080],
FrameRate=24)
Troubleshooting
| Problem | Solution |
|---|
PARAVIEW_HOME not set | export PARAVIEW_HOME=/path/to/ParaView |
pvpython not found | Add $PARAVIEW_HOME/bin to PATH or use full path |
| pvserver not found | Check PARAVIEW_HOME path is correct |
| Port already in use | Use --port to specify different port |
| Connection failed | Check firewall, try checking PARAVIEW_HOME status |
| "No active source" | Load data first before applying filters |
| Transfer function not working | Check field name matches array name exactly |
| Blank/empty screenshot | Call ResetCamera(renderView) before SaveScreenshot |
| Wrong bounds/range | Call UpdatePipeline() after loading data (required for EXODUS) |
ModuleNotFoundError: paraview | Run with pvpython, not plain python |
Threshold field not found | Use ['POINTS', name] or ['CELLS', name] to match array location |
GradientOfUnstructuredDataSet fails | Only works on unstructured grids; use Gradient for structured data |
WarpByVector produces no output | Check vector field has 3 components; verify field name |
PlotOverLine view blank | Create an XYChartView and assign it via AssignViewToLayout |
SaveAnimation — no timesteps | Data must have multiple time steps; single-timestep data cannot be animated |
SaveData to STL/OBJ fails | Input must be a surface (PolyData); apply Contour or ExtractSurface first |
Task Execution
When given $ARGUMENTS:
- Parse the task from the arguments
- Write a self-contained Python script following the template above
- Execute it with
pvpython script.py (or $PARAVIEW_HOME/bin/pvpython script.py)
- Read the output image with the Read tool to verify correctness
- If the result needs adjustment, iterate (max 5 rounds)
- Report the result to the user
Resources
references/api-reference-5.12.1.md - Complete Python API reference (v5.12.1)
references/operations.md - Common operations quick reference
references/examples.md - Complete example scripts