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:
label (str | None, default None) – Label of the class instance, e.g., to be displayed in the legend.
description (dict | Description | None, default None) – Object description properties.
color (str | None, default None) – A valid CSS color. May also be one of {‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’}.
opacity (float | None, default None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
path (dict | Path | None, default None) – Instance of
Pathor dict with equivalent key/value pairs; defines path marker and path line properties.model3d (list[Trace3d | dict] | None, default None) – List of traces where each is a
Trace3dinstance or dict of equivalent key/value pairs. Defines an additional user-defined 3D model positioned relative to the main object and transformed with it. Can replace the original 3D representation.arrow (dict | Arrow | None, default None) –
Arrowinstance or dict with keys'show','size'.
- as_dict(flatten=False, separator='.')#
Returns recursively a nested dictionary with all properties objects of the class
- Parameters:
flatten (bool) – If
True, the nested dictionary gets flatten out with provided separator for the dictionary keysseparator (str) – the separator to be used when flattening the dictionary. Only applies if
flatten=True
- copy()#
returns a copy of the current class instance
- update(arg=None, _match_properties=True, _replace_None_only=False, **kwargs)#
Updates the class properties with provided arguments, supports magic underscore notation
- Parameters:
_match_properties (bool) – If
True, checks if provided properties over keyword arguments are matching the current object properties. An error is raised if a non-matching property is found. IfFalse, theupdatemethod does not raise any error when an argument is not matching a property._replace_None_only – updates matching properties that are equal to
None(not already been set)
- Return type:
self
- property arrow#
Arrow object or dict with show, size, width, style, color properties/keys.
- property color#
A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].
- property description#
Description with ‘text’ and ‘show’ properties.
- property label#
Label of the class instance, e.g. to be displayed in the legend.
- property legend#
Legend with ‘show’ property.
- property line#
Line object or dict with show, width, style, color properties/keys.
- property model3d#
3d object representation properties.
- property opacity#
Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
- property path#
An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.
- class magpylib.graphics.style.DipoleStyle(**kwargs)#
Bases:
BaseStyle,DipolePropertiesStyling properties for dipole objects.
- Parameters:
label (str | None, default None) – Label of the class instance, e.g., to be displayed in the legend.
description (dict | Description | None, default None) – Object description properties.
color (str | None, default None) – A valid CSS color. May also be one of {‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’}.
opacity (float | None, default None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
path (dict | Path | None, default None) – Instance of
Pathor dict with equivalent key/value pairs; defines path marker and path line properties.model3d (list[Trace3d | dict] | None, default None) – List of traces where each is a
Trace3dinstance or dict of equivalent key/value pairs. Defines an additional user-defined 3D model positioned relative to the main object and transformed with it. Can replace the original 3D representation.size (float | None, default None) – Ratio of dipole size to canvas size (positive).
pivot ({'tail', 'middle', 'tip'} | None, default None) – The part of the arrow anchored to the grid about which it rotates.
- as_dict(flatten=False, separator='.')#
Returns recursively a nested dictionary with all properties objects of the class
- Parameters:
flatten (bool) – If
True, the nested dictionary gets flatten out with provided separator for the dictionary keysseparator (str) – the separator to be used when flattening the dictionary. Only applies if
flatten=True
- copy()#
returns a copy of the current class instance
- update(arg=None, _match_properties=True, _replace_None_only=False, **kwargs)#
Updates the class properties with provided arguments, supports magic underscore notation
- Parameters:
_match_properties (bool) – If
True, checks if provided properties over keyword arguments are matching the current object properties. An error is raised if a non-matching property is found. IfFalse, theupdatemethod does not raise any error when an argument is not matching a property._replace_None_only – updates matching properties that are equal to
None(not already been set)
- Return type:
self
- property color#
A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].
- property description#
Description with ‘text’ and ‘show’ properties.
- property label#
Label of the class instance, e.g. to be displayed in the legend.
- property legend#
Legend with ‘show’ property.
- property model3d#
3d object representation properties.
- property opacity#
Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
- property path#
An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.
- property pivot#
The part of the arrow that is anchored to the X, Y grid. The arrow rotates about this point. Can be one of [‘tail’, ‘middle’, ‘tip’].
- property size#
Positive value for ratio of dipole size to canvas size.
- property sizemode#
Sizemode of the dipole.
- class magpylib.graphics.style.MagnetStyle(**kwargs)#
Bases:
BaseStyle,MagnetPropertiesStyling properties for homogeneous magnet classes.
- Parameters:
label (str | None, default None) – Label of the class instance, e.g., to be displayed in the legend.
description (dict | Description | None, default None) – Object description properties.
color (str | None, default None) – A valid CSS color. May also be one of {‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’}.
opacity (float | None, default None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
path (dict | Path | None, default None) – Instance of
Pathor dict with equivalent key/value pairs; defines path marker and path line properties.model3d (list[Trace3d | dict] | None, default None) – List of traces where each is a
Trace3dinstance or dict of equivalent key/value pairs. Defines an additional user-defined 3D model positioned relative to the main object and transformed with it. Can replace the original 3D representation.magnetization (dict | Magnetization | None, default None) – Magnetization styling with keys
'show','size','color', or aMagnetizationinstance.
- as_dict(flatten=False, separator='.')#
Returns recursively a nested dictionary with all properties objects of the class
- Parameters:
flatten (bool) – If
True, the nested dictionary gets flatten out with provided separator for the dictionary keysseparator (str) – the separator to be used when flattening the dictionary. Only applies if
flatten=True
- copy()#
returns a copy of the current class instance
- update(arg=None, _match_properties=True, _replace_None_only=False, **kwargs)#
Updates the class properties with provided arguments, supports magic underscore notation
- Parameters:
_match_properties (bool) – If
True, checks if provided properties over keyword arguments are matching the current object properties. An error is raised if a non-matching property is found. IfFalse, theupdatemethod does not raise any error when an argument is not matching a property._replace_None_only – updates matching properties that are equal to
None(not already been set)
- Return type:
self
- property color#
A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].
- property description#
Description with ‘text’ and ‘show’ properties.
- property label#
Label of the class instance, e.g. to be displayed in the legend.
- property legend#
Legend with ‘show’ property.
- property magnetization#
Magnetization instance with ‘show’, ‘size’, ‘color’ properties or a dictionary with equivalent key/value pairs.
- property model3d#
3d object representation properties.
- property opacity#
Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
- property path#
An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.
- class magpylib.graphics.style.SensorStyle(**kwargs)#
Bases:
BaseStyle,SensorPropertiesStyling properties for the Sensor class.
- Parameters:
label (str | None, default None) – Label of the class instance, e.g., to be displayed in the legend.
description (dict | Description | None, default None) – Object description properties.
color (str | None, default None) – A valid CSS color. May also be one of {‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’}.
opacity (float | None, default None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
path (dict | Path | None, default None) – Instance of
Pathor dict with equivalent key/value pairs; defines path marker and path line properties.model3d (list[Trace3d | dict] | None, default None) – List of traces where each is a
Trace3dinstance or dict of equivalent key/value pairs. Defines an additional user-defined 3D model positioned relative to the main object and transformed with it. Can replace the original 3D representation.size (float | None, default None) – Ratio of sensor size to canvas size (positive).
pixel (dict | Pixel | None, default None) –
Pixelinstance or dict with equivalent key/value pairs (e.g.,color,size).arrows (dict | ArrowCS | None, default None) –
ArrowCSinstance or dict with equivalent key/value pairs (e.g.,color,size).
- as_dict(flatten=False, separator='.')#
Returns recursively a nested dictionary with all properties objects of the class
- Parameters:
flatten (bool) – If
True, the nested dictionary gets flatten out with provided separator for the dictionary keysseparator (str) – the separator to be used when flattening the dictionary. Only applies if
flatten=True
- copy()#
returns a copy of the current class instance
- update(arg=None, _match_properties=True, _replace_None_only=False, **kwargs)#
Updates the class properties with provided arguments, supports magic underscore notation
- Parameters:
_match_properties (bool) – If
True, checks if provided properties over keyword arguments are matching the current object properties. An error is raised if a non-matching property is found. IfFalse, theupdatemethod does not raise any error when an argument is not matching a property._replace_None_only – updates matching properties that are equal to
None(not already been set)
- Return type:
self
- property arrows#
ArrowCS object or dict with equivalent key/value pairs (e.g. color, size).
- property color#
A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].
- property description#
Description with ‘text’ and ‘show’ properties.
- property label#
Label of the class instance, e.g. to be displayed in the legend.
- property legend#
Legend with ‘show’ property.
- property model3d#
3d object representation properties.
- property opacity#
Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.
- property path#
An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.
- property pixel#
Pixel object or dict with equivalent key/value pairs (e.g. color, size).
- property size#
Positive float for ratio of sensor to canvas size.
- property sizemode#
Sizemode of the sensor.