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 providedSelection
are 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
.filter
andtransmit
- Used by thepovray
module 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 providedSelection
are drawn.offset
- Local offset vector for labels. Can be aList
, aMatrix
or a function.dirn
- Text direction for labels. Can be aList
, aMatrix
or a function.vertical
- Text vertical direction. Can be aList
, aMatrix
or a function.color
- Label color. Can be aColor
object or aDictionary
of 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.filter
andtransmit
- Used by thepovray
module 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
- AColormap
object to use. The field is automatically scaled.scalebar
- AScalebar
object to use.style
- Plot style. See below.filter
andtransmit
- Used by thepovray
module to indicate transparency.cmin
andcmax
- 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
- ColorMesh
elements by the corresponding value of theField
.interpolate
- InterpolateField
quantities onto higher elements.
ScaleBar
Represents a scalebar for a plot:
Show(plotfield(field, scalebar=ScaleBar(posn=[1.2,0,0])))
ScaleBar
s can be created with many adjustable parameters:
nticks
- Maximum number of ticks to show.posn
- Position to draw theScaleBar
.length
- Length ofScaleBar
to draw.dirn
- Direction to draw theScaleBar
in.tickdirn
- Direction to draw the ticks in.colormap
-ColorMap
to 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.