Plot.Axis

class Axis(unit=<NL.CommonConcepts.PhysicalQuantity.Unit object>)

An Axis defines the x- or y-axis in a plot. The axis specifies limits, scale, label, fonts, ticks and grids.

Parameters:

unit (Unit) – The unit of the axis.

addItem(item, emit=True)

Add item as child of this item.

Parameters:
  • item (PlotItem based) – The item.

  • emit (bool) – True, if change should be emitted.

addSubscriber(subscriber)

Add a subscriber. Each subscriber is called once every time the plot item updates.

Parameters:

subscriber (bound method) – The subscriber. Must be callable.

addTag(*args)

Add tag. Used for grouping plot items.

Parameters:

*args (tuple of str) – The tags to add.

applyStyle(style_scheme=None, style_properties=None)

Apply style properties from a style scheme.

Parameters:
  • style_scheme (dict) – The style scheme.

  • style_properties (dict | None) – A specific set of style properties to apply. If None, the style properties are retrieved from the plot model using the given style scheme.

autoscalePadding()

. :returns: The padding used when autoscaling. :rtype: 2-tuple of float

checkAutoScaleIncludeZero()

Utility to check if including zero is possible and if the option is selected.

Returns:

True, if we can and should include zero.

Return type:

bool

color()

The color of the axis and the axis label.

copy()

Make a copy of the plot storable by using the serialize/deserialize functionality.

This creates a new instance with a new id, but all other properties copied.

emit(key, value=None)

Emit a single key and value change to all subscribers.

Parameters:
  • key (str) – The key to emit.

  • value (object) – The value to emit.

classmethod fromProperties(properties)

Create a plot storable from a dict of properties.

Used when deserializing a PlotStorable.

Parameters:

properties (dict) – The properties which are used to populate the properties dict of the newly created plot storable.

Returns:

The newly created PlotStorable.

Return type:

PlotStorable

hoverDetails()
Returns:

The current hover details.

Return type:

dict | None

isAutoScaleZeroIncluded()
Returns:

True, if the value zero should be explicitly included/shown on this axis.

Return type:

bool

isHoverable()
Returns:

True, if hoverable.

Return type:

bool

isHovered()
Returns:

True, if the item is hovered.

Return type:

bool

isLocked()
Returns:

True if the axis scroll is locked.

Return type:

bool

isMajorGridOn()
Returns:

True if major grid is shown.

Return type:

bool

isMinorGridOn()
Returns:

True if the minor grid is shown.

Return type:

bool

isMirrored()
Returns:

True, if ticks and label are mirrored.

Return type:

bool

isSelectable()
Returns:

True, if the item is selectable.

Return type:

bool

isSelected()
Returns:

True, if the item is selected.

Return type:

bool

isVisible()
Returns:

True, if the item is visible.

Return type:

bool

isZeroLineOn()
Returns:

True if zero line is shown.

Return type:

bool

items(selected=None, tag=None)

Return the requested items.

The optional selected key word filter selected and deselected lines, with the options:

  • True : Only selected items

  • False : Only unselected items

  • None : All items.

Parameters:
  • selected (None | bool) – True, if only selected items should be returned.

  • tag (str) – The tag to filter on.

Returns:

The child items with the selected filtering.

Return type:

items

label()
Returns:

The label of the axis.

Return type:

str

labelFontSize()
Returns:

The axis font size in points.

Return type:

float

limits()
Returns:

The limits of the axis.

Return type:

2-tuple of float

majorDivisions()
Returns:

The number of major ticks.

Return type:

Automatic | int

model()
Returns:

The model that this item belongs to.

Return type:

PlotModel | None

order()
Returns:

A number describing the current order of the item within the PlotModel. Can be used for sorting.

Return type:

int | None

owner()
Returns:

The owner type.

Return type:

int | enum

parent()
Returns:

The parent.

Return type:

PlotItem based | None

removeItem(item, emit=True)

Remove item from the child items.

Parameters:
  • item (PlotItem based) – The item to remove.

  • emit (bool) – True, if removal should be emitted.

removeSubscriber(subscriber)

Remove a subscriber method from the plot item updates.

Parameters:

subscriber (bound method) – The subscriber. Must be callable.

scale()
Returns:

Axis scale (‘linear’ | ‘log’).

Return type:

str

selectionDetails()
Returns:

The current selection details.

Return type:

dict | None

setAutoScaleIncludeZero(include_zero)
Parameters:

include_zero (bool) – True, if the value zero should be explicitly included/shown on this axis.

setAutoscalePadding(padding_lower, padding_upper)

Set autoscale padding. Do not emit changes.

Parameters:
  • padding_lower (float) – The lower padding.

  • padding_upper (float) – The upper padding.

setColor(color)

Set the color of the axis and the axis label.

Parameters:

color (str) – The color to set in hex format.

setHoverable(hoverable)

Enable or disable hover evetn. When enabled the line will be set to hovered, once the mouse hovers over the item.

Parameters:

hoverable (bool) – True, if the item should be sensitive to hover events.

setHovered(hovered, details=None)

Set hovered with some details. This is called once the mouse hovers over the item. Should only be called once hoverable has been enabled.

Parameters:
  • hovered (bool) – True, if the item was hovered.

  • details (dict | NoneType) – The hover details.

setLabel(label, font_size=None)

Set the label.

Parameters:
  • label (str) – The label.

  • font_size (float) – The absolute font size in points.

setLabelFontSize(font_size)
Parameters:

font_size (float) – The label font size in points.

setLimits(lower_limit=None, upper_limit=None)

Set axis limits.

Parameters:
  • lower_limit (float) – The lower limit.

  • upper_limit (float) – The upper limit.

setLocked(state)

Set the locked state of the axis.

Parameters:

state (bool) – True if the axis should be locked.

setMajorDivisions(major_divisions)

Set the number of major divisions of the axis.

Parameters:

major_divisions (Automatic | int) – The number of divisions.

setMajorGridOn(grid_on)
Parameters:

grid_on (bool) – Set major grid lines on/off.

setMinorGridOn(grid_on)
Parameters:

grid_on (bool) – Set minor grid lines on/off.

setMirrored(mirrored)

Set ticks and labels mirrored..

Parameters:

mirrored (bool) – True, if ticks should show up on the opposite site.

setOwner(owner)

Set the owner of the item (either OWNERS.MODEL or OWNERS.VIEW).

Parameters:

owner (int | enum) – The owner type.

setScale(scale)

Set scale.

Parameters:

scale (str) – The scale (‘linear’ or ‘log’).

setSelectable(selectable)

Set whether this item is selectable.

Parameters:

selectable (bool) – True, if the item should be selectable.

setSelected(selected, details=None)

Set the item as selected or unselected.

Parameters:
  • selected (bool) – True, if item should be selected.

  • details (dict | NoneType) – The selection details.

setTickFontSize(font_size)

Set the tick font size.

Parameters:

font_size (float) – The absolute font size in points.

setTicks(positions=None, labels=None, font_size=None, major_divisions=<class 'NL.ComputerScienceUtilities.NLFlag._NLFlag.Automatic'>, length=None, direction=None)

Set tick positions and labels for the axis.

Setting positions=None resets the ticks to use default locators and formatters.

Parameters:
  • positions (list) – List of tick float positions.

  • labels (list) – List of tick label strings.

  • font_size (float) – The absolute font size in points.

  • major_divisions ([type]) – [description].

  • length (float) – The length of ticks in points.

  • direction (enum) – The direction of ticks.

setUnit(unit)

Set the axis unit.

Parameters:

unit (Unit) – The unit.

setVisible(visible)

Set visible.

Parameters:

visible (bool) – True, if the item should be visible.

setZeroLineOn(line_on)
Parameters:

line_on (bool) – True, if zero-line should be shown.

styleProperties(style_scheme)

Check if the given style scheme has a style for this item.

Parameters:

style_scheme (dict) – The style scheme.

Returns:

The style, if any.

Return type:

dict | None

tags()
Returns:

The set of tags.

Return type:

set

tickDirection()
Returns:

The direction of ticks.

Return type:

enum

tickFontSize()
Returns:

The tick font size in points.

Return type:

float

tickLabels()
Returns:

The list of tick labels.

Return type:

list

tickLength()
Returns:

The length of ticks in points.

Return type:

float

ticks()
Returns:

The a list of the tick positions as floats.

Return type:

list

unit()
Returns:

The unit of the axis.

Return type:

Unit