Area module

class lys.widgets.canvas.interface.Area.CanvasMargin(canvas)[source]

Bases: CanvasPart

Abstract base class for Margin. All methods in this interface can be accessed from CanvasBase instance. Developers should implement a abstract method _setMargin(left, right, bottom, top).

Examples:

from lys import display
g = display([1,2,3])
g.canvas.setMargin(0, 0.7, 0.2, 0.9)  # 0 means auto
print(g.canvas.getMargin())           # (0, 0.7, 0.2, 0.9)
getMargin(raw=False)[source]

Get margin of canvas.

Returns

The value of margin. If raw is False, actual margin used for display is returned.

Return type

float of length 4

marginChanged

Emitted when margin is changed.

refreshMargin()[source]

Refresh margin based on the present setting.

setMargin(left=0, right=0, bottom=0, top=0)[source]

Set margin of canvas. Zero means auto.

Parameters
  • left (float) – The position of the left edge of the subplots, as a fraction of the figure width.

  • right (float) – The position of the right edge of the subplots, as a fraction of the figure width.

  • bottom (float) – The position of the bottom edge of the subplots, as a fraction of the figure height.

  • top (float) – The position of the top edge of the subplots, as a fraction of the figure height.

class lys.widgets.canvas.interface.Area.CanvasSize(canvas)[source]

Bases: CanvasPart

Abstract base class of CanvasSize. All methods in this interface can be accessed from CanvasBase instance. Developers should implement abstract methods _setAuto, _setAbsolute, _setAspect, and _getSize.

Examples:

from lys import display
g = display([1,2,3])
g.canvas.setCanvasSize("Width", "Absolute", 4)
g.canvas.setCanvasSize("Height", "Absolute", 5)
print(g.canvas.getCanvasSize()) # (4, 5)
canvasResized

Emitted when canvas size is changed.

getCanvasSize()[source]

Get canvas size.

Returns

Canvas size.

Return type

float of length 2

getSizeParams(type)[source]

Get size parameters (mode, value, axis1, axis2) as dictionary.

See setCanvasSize() for the description of each parameters

Returns

size parameters.

Return type

dictionary

parentResized()[source]
refreshCanvasSize()[source]
setCanvasSize(type, mode, value=0, axis1=None, axis2=None)[source]

Set the size of the canvas.

When mode is ‘Auto’, the canvas size is set to value, and is changed freely. If value is zero, it remains present canvas size.

When mode is ‘Absolute’, the canvas size is set to value in cm.

When mode is ‘Per Unit’, the canvas size is set to value * (range of axis1).

When mode is ‘Aspect’, the aspect ratio is set to value.

When mode is ‘Plan’, the canvas size is set to value * (range of axis1) / (range of axis2).

Parameters
  • type ('Width' or 'Height') – specify which size is set.

  • mode ('Auto' or 'Absolute' or 'Per Unit' or 'Aspect' or 'Plan') – see description.

  • value (float) – the value to be set.

  • axis1 ('Left' or 'Right' or 'Bottom' or 'Top') – see description.

  • axis2 ('Left' or 'Right' or 'Bottom' or 'Top') – see description.