Axes module
- class lys.widgets.canvas.interface.Axes.CanvasAxes(canvas)[source]
Bases:
CanvasPart
Interface to access axes of canvas. All methods in this interface can be accessed from
CanvasBase
instance. Developers should implement a abstract methods.- addAxis(axis)[source]
Add top/right axis to the canvas.
- Parameters
axis ('Top' or 'Right') – The axis to be added.
- axisChanged
Emitted when the right or top axis is added.
- axisIsValid(axis)[source]
Return if the specified axis is valid.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The name of axis.
- Returns
The axis is valid or not.
- Return type
bool
Example:
from lys import display g = display([1,2,3]) g.canvas.axisIsValid("Left") # True g.canvas.axisIsValid("Right") # False
- axisList()[source]
Return list of valid axes.
- Returns
The list of valid axes.
- Return type
list of axis name
Example:
from lys import display g = display([1,2,3]) g.canvas.axisList() # ['Left', 'Bottom']
- axisRangeChanged
Emitted when the range of axes is changed.
- getAxisColor(axis)[source]
Get color of axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose thick is changed.
- Returns
The color code of the axis, such as ‘#123456’.
- Return type
str
See also
- getAxisMode(axis)[source]
Get axis mode.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose mode is changed.
- Returns
The scale mode of the axis.
- Return type
‘linear’ or ‘log’
See also
- getAxisRange(axis)[source]
Get the axis view limits.
If the axis is in ‘BottomLeft’, ‘BottomRight’, ‘TopLeft’, or ‘TopRight’, both horizontal and vertical range is returned in the form of [(x1, x2), (y1, y2)].
- Parameters
axis ('Left', 'Right', 'Bottom', 'Top', 'BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis.
- Returns
The axis range in the form of (x1, x2).
- Return type
length 2 sequence
See also
- getAxisThick(axis)[source]
Get thick of axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose thick is obtained.
- Returns
The thickness of the axis.
- Return type
float
See also
- getMirrorAxis(axis)[source]
Get the state of mirror axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose mirror axis state is checked.
- Returns
If value is True (False), the mirror axis is shown (hidden).
- Return type
bool
See also
- isAutoScaled(axis)[source]
Return if the specified axis is auto-scaled.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The name of axis.
- Returns
The axis is auto-scaled or not.
- Return type
bool
Example:
from lys import display g = display([1,2,3]) g.canvas.setAxisRange('Bottom', [0, 3]) g.canvas.isAutoScaled('Left') # True g.canvas.isAutoScaled('Bottom') # False
See also
- isRangeSelected()[source]
Return True if the selected range is not empty.
- Returns
The result.
- Return type
bool
- selectedRange()[source]
Return the selected range that is set by
setSelectedRange()
method.- Returns
The selected range in the form of [(x1, y1), (x2, y2)]
- Return type
2*2 sequence
- selectedRangeChanged
Emitted when the selected range of axes is changed.
- setAutoScaleAxis(axis)[source]
Autoscale the axis view to the data.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose range is changed.
Example:
from lys import display g = display([1,2,3]) g.canvas.setAutoScaleAxis('Left') g.canvas.getAxisRange('Left') # [0.9, 3.1]
See also
- setAxisColor(axis, color)[source]
Set color of axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose thick is changed.
color (str) – The color code of the axis, such as ‘#123456’.
See also
- setAxisMode(axis, mode)[source]
Set axis mode.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose mirror axis is enabled/disabled.
mode ('linear' or 'log') – The scale of the axis is set to mode.
See also
- setAxisRange(axis, range)[source]
Set the axis view limits.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose range is changed.
range (length 2 sequence) – minimum and maximum range of view.
Example:
from lys import display g = display([1,2,3]) g.canvas.setAxisRange('Left', [0, 5]) g.canvas.getAxisRange('Left') # [0, 5]
See also
- setAxisThick(axis, thick)[source]
Set thick of axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose thick is changed.
thick (float) – The thickness of the axis.
See also
- setMirrorAxis(axis, value)[source]
Enable/disable mirror axis.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose mirror axis is enabled/disabled.
value (bool) – If value is True (False), the mirror axis is shown (hidden).
See also
- setSelectedRange(region)[source]
Set the selected range of the graph.
The selected range can be obtained by
selectedRange()
- Parameters
region – The region to be selected in the form of [(x1, y1), (x2, y2)].
- class lys.widgets.canvas.interface.Axes.CanvasTicks(canvas)[source]
Bases:
CanvasPart
Interface to access ticks of canvas. All methods in this interface can be accessed from
CanvasBase
instance. Developers should implement a abstract methods.- getTickDirection(axis)[source]
Get direction of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
- Returns
This method returns whether the ticks are shown in the box.
- Return type
‘in’ or ‘out’
See also
- getTickInterval(axis, which='major', raw=True)[source]
Get interval of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
which ('major' or 'minor') – Return major (minor) tick interval depending on which.
- Returns
The interval of the ticks.
- Return type
float
See also
- getTickLength(axis, which='major')[source]
Get length of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
which ('major' or 'minor' or 'both') – Return major (minor) tick length depending on which.
- Returns
The length of the ticks.
- Return type
float
See also
- getTickVisible(axis, mirror=False, which='major')[source]
Get visibility of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
which ('major' or 'minor') – This method returns major (minor) tick visibility depending on which.
See also
- getTickWidth(axis, which='major')[source]
Get thick of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
which ('major' or 'minor') – Return major (minor) tick width depending on which.
- Returns
The width of the ticks.
- Return type
float
See also
- setTickDirection(axis, direction)[source]
Set direction of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
value ('in' or 'out') – Whether the ticks are shown in the box.
See also
- setTickInterval(axis, value=0, which='major')[source]
Set interval of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
value (float) – The length of the axis. Zero means automatic interval.
which ('major' or 'minor' or 'both') – Change major (minor) tick length depending on which.
See also
- setTickLength(axis, value, which='major')[source]
Set length of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
value (float) – The length of the axis.
which ('major' or 'minor' or 'both') – Change major (minor) tick length depending on which.
See also
- setTickVisible(axis, value, mirror=False, which='both')[source]
Set visibility of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
value (bool) – If it is True (False), the ticks are shown (hidden).
which ('major' or 'minor' or 'both') – Change major (minor) tick length depending on which.
See also
- setTickWidth(axis, value, which='major')[source]
Set thick of ticks.
- Parameters
axis ('Left' or 'Right' or 'Bottom' or 'Top') – The axis whose ticks are changed.
value (float) – The width of the axis.
which ('major' or 'minor' or 'both') – Change major (minor) tick width depending on which.
See also