magpylib.graphics.style package#
The magpylib.display.style sub-package provides different object styles.
- class magpylib.graphics.style.CurrentStyle(**kwargs)#
Bases:
BaseStyle,CurrentPropertiesStyling properties for line current classes.
- Parameters:
arrow (dict or Arrow object, default=None) – Current arrow properties.
line (dict or CurrentLine object, default=None) – Current line properties.
label – See BaseStyle.
description – See BaseStyle.
legend – See BaseStyle.
color – See BaseStyle.
opacity – See BaseStyle.
path – See BaseStyle.
model3d – See BaseStyle.
- 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.
- arrow#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- color#
A CSS color field, normalized by color_validator.
- description#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- label#
A string field, optionally coercing any input via str().
- legend#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- line#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- model3d#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- opacity#
A float or int field with optional bounds.
- path#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- class magpylib.graphics.style.DipoleStyle(**kwargs)#
Bases:
BaseStyle,DipolePropertiesStyling properties for dipole objects.
- Parameters:
size (float, default=None) – Positive float for ratio of dipole to canvas size.
sizemode ({'scaled', 'absolute'}, default=None) – Scale reference for the dipole size.
pivot ({'tail', 'middle', 'tip'}, default=None) – The part of the arrow anchored to the grid about which it rotates.
label – See BaseStyle.
description – See BaseStyle.
legend – See BaseStyle.
color – See BaseStyle.
opacity – See BaseStyle.
path – See BaseStyle.
model3d – See BaseStyle.
- 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.
- color#
A CSS color field, normalized by color_validator.
- description#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- label#
A string field, optionally coercing any input via str().
- legend#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- model3d#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- opacity#
A float or int field with optional bounds.
- path#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- pivot#
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.
- size#
A float or int field with optional bounds.
- sizemode#
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.
- class magpylib.graphics.style.MagnetStyle(**kwargs)#
Bases:
BaseStyle,MagnetPropertiesStyling properties for homogeneous magnet classes.
- Parameters:
magnetization (dict or Magnetization object, default=None) – Magnetization styling properties.
label – See BaseStyle.
description – See BaseStyle.
legend – See BaseStyle.
color – See BaseStyle.
opacity – See BaseStyle.
path – See BaseStyle.
model3d – See BaseStyle.
- 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.
- color#
A CSS color field, normalized by color_validator.
- description#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- label#
A string field, optionally coercing any input via str().
- legend#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- magnetization#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- model3d#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- opacity#
A float or int field with optional bounds.
- path#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- class magpylib.graphics.style.SensorStyle(**kwargs)#
Bases:
BaseStyle,SensorPropertiesStyling properties for the Sensor class.
- Parameters:
size (float, default=None) – Positive float for ratio of sensor to canvas size.
sizemode ({'scaled', 'absolute'}, default=None) – Scale reference for the sensor size.
pixel (dict or Pixel object, default=None) – Pixel styling properties.
arrows (dict or ArrowCS object, default=None) – Coordinate system arrows properties.
label – See BaseStyle.
description – See BaseStyle.
legend – See BaseStyle.
color – See BaseStyle.
opacity – See BaseStyle.
path – See BaseStyle.
model3d – See BaseStyle.
- 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.
- arrows#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- color#
A CSS color field, normalized by color_validator.
- description#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- label#
A string field, optionally coercing any input via str().
- legend#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- model3d#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- opacity#
A float or int field with optional bounds.
- path#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- pixel#
A child PropertyNode, instantiated lazily on first access.
Assigning a dict builds a fresh node from it (replace, not merge — use
update()to merge); assigningNoneresets to a pristine node. Withfrom_str, assigning a string builds a node with that field set, e.g.style.description = "hello"forNested(Description, from_str="text").
- size#
A float or int field with optional bounds.
- sizemode#
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.