set_scalar()
Configures scalar field coloring for the loaded mesh.
set_scalar() is part of the visualization pipeline. Calling it only stores the configuration — the scalar actor is not added to the scene until show() or export() triggers a full rebuild. This means you can call set_scalar() multiple times before rendering and only the last call takes effect, and the configuration is reapplied automatically on every subsequent show()/export() call (e.g. after changing the active time step).
Parameters
name(Literal[...]) — Name of the scalar array to plot (must exist in the mesh arrays)."B-Mag (T)""Flux (A/m)""J-Mag (A/m^2)""Loss (W/m^3)""F Nodal-Mag (N/m^3)""F Lorents-Mag (N/m^3)""Heat Density (W/m^3)""Heat (W)"
mode("node" | "element", default:"node") — Whethernameis point data ("node") or cell data ("element").**kwargs— Forwarded toadd_mesh()for the scalar mesh actor.
Useful **kwargs include cmap, clim, show_edges, edge_color, edge_opacity, show_scalar_bar, scalar_bar_args.
Returns
Plotter— returnsselfto enable chaining.
Examples
from pyemsi import Plotter, examples
file_path = examples.ipm_motor_path()
plt = Plotter(file_path)
plt.set_scalar("B-Mag (T)", cmap="viridis", edge_color="red", edge_opacity=0.2, show_scalar_bar=False)
plt.plotter.view_xy()
plt.show()
from pyemsi import Plotter, examples
file_path = examples.transient_path()
plt = Plotter(file_path)
plt.set_scalar("B-Mag (T)", mode="element", show_edges=False, show_scalar_bar=False)
plt.set_block_visibility("4", False)
plt.show()
See also
set_contour()— add contour lines on top of the scalar fieldset_vector()— overlay vector glyphsset_feature_edges()— configure edge overlayset_block_visibility()— hide/show individual mesh blocksshow()— trigger rendering and apply the full pipelineexport()— render and save a screenshot