magpylib.graphics.style package#

The magpylib.display.style sub-package provides different object styles.

class magpylib.graphics.style.CurrentStyle(**kwargs)#

Bases: BaseStyle, CurrentProperties

Defines styling properties of line current classes.

Parameters:
  • label (str, default=None) – Label of the class instance, e.g. to be displayed in the legend.

  • description (dict or Description object, default=None) – Object description properties.

  • color (str, default=None) – A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

  • opacity (float, default=None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.

  • path (dict or Path object, default=None) – An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.

  • model3d (list of Trace3d objects, default=None) – A list of traces where each is an instance of Trace3d or dictionary of equivalent key/value pairs. Defines properties for an additional user-defined model3d object which is positioned relatively to the main object to be displayed and moved automatically with it. This feature also allows the user to replace the original 3d representation of the object.

  • arrow (dict or Arrow object, default=None) – Arrow object or dict with ‘show’, ‘size’ properties/keys.

property arrow#

Arrow object or dict with show, size, width, style, color properties/keys.

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 keys

  • separator (str) – the separator to be used when flattening the dictionary. Only applies if flatten=True

property color#

A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

copy()#

returns a copy of the current class instance

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.

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. If False, the update method 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

class magpylib.graphics.style.DipoleStyle(**kwargs)#

Bases: BaseStyle, DipoleProperties

Defines the styling properties of dipole objects.

Parameters:
  • label (str, default=None) – Label of the class instance, e.g. to be displayed in the legend.

  • description (dict or Description object, default=None) – Object description properties.

  • color (str, default=None) – A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

  • opacity (float, default=None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.

  • path (dict or Path object, default=None) – An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.

  • model3d (list of Trace3d objects, default=None) – A list of traces where each is an instance of Trace3d or dictionary of equivalent key/value pairs. Defines properties for an additional user-defined model3d object which is positioned relatively to the main object to be displayed and moved automatically with it. This feature also allows the user to replace the original 3d representation of the object.

  • size (float, default=None) – Positive float for ratio of dipole size to canvas size.

  • pivot (str, default=None) – 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’].

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 keys

  • separator (str) – the separator to be used when flattening the dictionary. Only applies if flatten=True

property color#

A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

copy()#

returns a copy of the current class instance

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.

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. If False, the update method 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

class magpylib.graphics.style.MagnetStyle(**kwargs)#

Bases: BaseStyle, MagnetProperties

Defines styling properties of homogeneous magnet classes.

Parameters:
  • label (str, default=None) – Label of the class instance, e.g. to be displayed in the legend.

  • description (dict or Description object, default=None) – Object description properties.

  • color (str, default=None) – A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

  • opacity (float, default=None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.

  • path (dict or Path object, default=None) – An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.

  • model3d (list of Trace3d objects, default=None) – A list of traces where each is an instance of Trace3d or dictionary of equivalent key/value pairs. Defines properties for an additional user-defined model3d object which is positioned relatively to the main object to be displayed and moved automatically with it. This feature also allows the user to replace the original 3d representation of the object.

  • magnetization (dict or Magnetization, default=None) – Magnetization styling with ‘show’, ‘size’, ‘color’ properties or a dictionary with equivalent key/value pairs.

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 keys

  • separator (str) – the separator to be used when flattening the dictionary. Only applies if flatten=True

property color#

A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

copy()#

returns a copy of the current class instance

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.

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. If False, the update method 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

class magpylib.graphics.style.SensorStyle(**kwargs)#

Bases: BaseStyle, SensorProperties

Defines the styling properties of the Sensor class.

Parameters:
  • label (str, default=None) – Label of the class instance, e.g. to be displayed in the legend.

  • description (dict or Description object, default=None) – Object description properties.

  • color (str, default=None) – A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

  • opacity (float, default=None) – Object opacity between 0 and 1, where 1 is fully opaque and 0 is fully transparent.

  • path (dict or Path object, default=None) – An instance of Path or dictionary of equivalent key/value pairs, defining the object path marker and path line properties.

  • model3d (list of Trace3d objects, default=None) – A list of traces where each is an instance of Trace3d or dictionary of equivalent key/value pairs. Defines properties for an additional user-defined model3d object which is positioned relatively to the main object to be displayed and moved automatically with it. This feature also allows the user to replace the original 3d representation of the object.

  • size (float, default=None) – Positive float for ratio of sensor size to canvas size.

  • pixel (dict, Pixel, default=None) – Pixel object or dict with equivalent key/value pairs (e.g. color, size).

  • arrows (dict, ArrowCS, default=None) – ArrowCS object or dict with equivalent key/value pairs (e.g. color, size).

property arrows#

ArrowCS object 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 keys

  • separator (str) – the separator to be used when flattening the dictionary. Only applies if flatten=True

property color#

A valid css color. Can also be one of [‘r’, ‘g’, ‘b’, ‘y’, ‘m’, ‘c’, ‘k’, ‘w’].

copy()#

returns a copy of the current class instance

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.

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. If False, the update method 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