Plot
The plot module provides visualization capabilities for Meshes, Selections and Fields. These functions produce Graphics objects that can be displayed with Show.
To use the module, first import it:
import plot
Plotmesh
Visualizes a Mesh object:
var g = plotmesh(mesh)
Plotmesh accepts a number of optional arguments to control what is displayed:
selection- Only elements in a providedSelectionare drawn.grade- Only draw the specified grade. This can also be a list of multiple grades to draw.color- Draw the mesh in a providedColor.filterandtransmit- Used by thepovraymodule to indicate transparency.
Plotmeshlabels
Draws the ids for elements in a Mesh:
var g = plotmeshlabels(mesh)
Plotmeshlabels accepts a number of optional arguments to control the output:
grade- Only draw the specified grade. This can also be a list of multiple grades to draw.selection- Only labels in a providedSelectionare drawn.offset- Local offset vector for labels. Can be aList, aMatrixor a function.dirn- Text direction for labels. Can be aList, aMatrixor a function.vertical- Text vertical direction. Can be aList, aMatrixor a function.color- Label color. Can be aColorobject or aDictionaryof colors for each grade.fontsize- Font size to use.
Plotselection
Visualizes a Selection object:
var g = plotselection(mesh, sel)
Plotselection accepts a number of optional arguments to control what is displayed:
grade- Only draw the specified grade. This can also be a list of multiple grades to draw.filterandtransmit- Used by thepovraymodule to indicate transparency.
Plotfield
Visualizes a scalar Field object:
var g = plotfield(field)
Plotfield accepts a number of optional arguments to control what is displayed:
grade- Draw the specified grade.colormap- AColormapobject to use. The field is automatically scaled.scalebar- AScalebarobject to use.style- Plot style. See below.filterandtransmit- Used by thepovraymodule to indicate transparency.cminandcmax- Can be used to define the data range covered. Values beyond these limits will be colored by the lower/upper bound of the colormap accordingly.
Supported plot styles:
default- ColorMeshelements by the corresponding value of theField.interpolate- InterpolateFieldquantities onto higher elements.
ScaleBar
Represents a scalebar for a plot:
Show(plotfield(field, scalebar=ScaleBar(posn=[1.2,0,0])))
ScaleBars can be created with many adjustable parameters:
nticks- Maximum number of ticks to show.posn- Position to draw theScaleBar.length- Length ofScaleBarto draw.dirn- Direction to draw theScaleBarin.tickdirn- Direction to draw the ticks in.colormap-ColorMapto use.textdirn- Direction to draw labels in.textvertical- Label vertical direction.fontsize- Fontsize for labelstextcolor- Color for labels
You can draw the ScaleBar directly by calling the draw method:
sb.draw(min, max)
where min and max are the minimum and maximum values to display on the scalebar.