magpylib.graphics package#
Additional plotting features
- class magpylib.graphics.Trace3d(**kwargs)#
Bases:
PropertyNodeUser-defined 3D model trace that moves/rotates with its parent object.
- Parameters:
backend (str, default 'generic') – Plotting backend for this trace: ‘generic’, any of the built-in backends in
magpylib.SUPPORTED_PLOTTING_BACKENDS, or a backend registered at runtime.constructor (str | None, default None) – Name of the constructor function/method to build the 3D model (e.g.,
'plot_trisurf','Mesh3d'). Must match the selected backend.args (tuple | callable | None, default None) – Positional arguments for the constructor, or a callable returning them.
kwargs (dict | callable | None, default None) – Keyword arguments for the constructor, or a callable returning them.
coordsargs (dict | None, default None) – Names of coordinate arrays to be transformed; by default
{"x": "x", "y": "y", "z": "z"}.show (bool, default True) – Show or hide the resulting model3d object.
scale (float, default 1) – Multiplier applied to the trace vertex coordinates.
updatefunc (callable | None, default None) – Callable with no arguments returning a dictionary of trace parameters to update at show time.
- as_dict(flatten=False, separator='.')#
Return all effective values as a nested dict (flatten=True for a flat dict with separator-joined keys).
- copy()#
Return a detached, unobserved deep copy.
- get(path)#
Return the value at a dotted path, e.g.
'arrow.width'.
- is_set(name)#
Return whether a direct property holds an explicitly set value (for child nodes: whether anything in the subtree is set).
- merged(*layers)#
Return a copy where unset properties are filled from the given layers, first-set-wins (self has the highest priority).
- observe(callback)#
Register
callback(path, value)to fire on any change in this subtree;pathis the dotted path of the changed property relative to this node.
- classmethod schema()#
Return the JSON-Schema description of the field tree.
- set(path, value)#
Set the value at a dotted path and return self.
- set_values(separator='.')#
Return a flat
{dotted_path: value}dict of all explicitly set leaf values.
- unobserve(callback)#
Unregister a previously registered callback.
- update(arg=None, _match_properties=True, _replace_None_only=False, **kwargs)#
Update properties from a dict and/or keyword arguments, supporting magic underscore notation. Nested dicts merge into child nodes.
- Parameters:
_match_properties (bool) – If
True(default), unknown property names raise an AttributeError; ifFalsethey are silently ignored._replace_None_only (bool) – If
True, only properties that are not explicitly set get updated.
- args#
A tuple, or a callable returning one.
- backend#
A field restricted to a set of allowed values.
The values are given either directly, or as a single zero-argument callable returning them, for sets that are only known at call time (e.g. the display backends registered so far). A callable is re-evaluated on every validate() and schema(), so a generated schema describes the choices as they stand at generation time.
- constructor#
A string field, optionally coercing any input via str().
- coordsargs#
A dict with ‘x’, ‘y’, ‘z’ keys naming coordinate arrays.
- kwargs#
A dict, or a callable returning one.
- scale#
A float or int field with optional bounds.
- show#
A strict True/False field.
- updatefunc#
A callable with no arguments returning a dict of Trace3d parameters.
Subpackages#
- magpylib.graphics.model3d package
- magpylib.graphics.style package
CurrentStyleCurrentStyle.as_dict()CurrentStyle.copy()CurrentStyle.get()CurrentStyle.is_set()CurrentStyle.merged()CurrentStyle.observe()CurrentStyle.schema()CurrentStyle.set()CurrentStyle.set_values()CurrentStyle.unobserve()CurrentStyle.update()CurrentStyle.arrowCurrentStyle.colorCurrentStyle.descriptionCurrentStyle.labelCurrentStyle.legendCurrentStyle.lineCurrentStyle.model3dCurrentStyle.opacityCurrentStyle.path
DipoleStyleDipoleStyle.as_dict()DipoleStyle.copy()DipoleStyle.get()DipoleStyle.is_set()DipoleStyle.merged()DipoleStyle.observe()DipoleStyle.schema()DipoleStyle.set()DipoleStyle.set_values()DipoleStyle.unobserve()DipoleStyle.update()DipoleStyle.colorDipoleStyle.descriptionDipoleStyle.labelDipoleStyle.legendDipoleStyle.model3dDipoleStyle.opacityDipoleStyle.pathDipoleStyle.pivotDipoleStyle.sizeDipoleStyle.sizemode
MagnetStyleMagnetStyle.as_dict()MagnetStyle.copy()MagnetStyle.get()MagnetStyle.is_set()MagnetStyle.merged()MagnetStyle.observe()MagnetStyle.schema()MagnetStyle.set()MagnetStyle.set_values()MagnetStyle.unobserve()MagnetStyle.update()MagnetStyle.colorMagnetStyle.descriptionMagnetStyle.labelMagnetStyle.legendMagnetStyle.magnetizationMagnetStyle.model3dMagnetStyle.opacityMagnetStyle.path
SensorStyleSensorStyle.as_dict()SensorStyle.copy()SensorStyle.get()SensorStyle.is_set()SensorStyle.merged()SensorStyle.observe()SensorStyle.schema()SensorStyle.set()SensorStyle.set_values()SensorStyle.unobserve()SensorStyle.update()SensorStyle.arrowsSensorStyle.colorSensorStyle.descriptionSensorStyle.labelSensorStyle.legendSensorStyle.model3dSensorStyle.opacitySensorStyle.pathSensorStyle.pixelSensorStyle.sizeSensorStyle.sizemode