Skip to content

plotynium.properties

plotynium.properties.CanvasProperties

CanvasProperties()

Canvas properties which has default values for width, height and margin values and has two extra attributes translate_x and translate_y for canvas placement.

Source code in plotynium/properties.py
def __init__(self):
    super().__init__(
        DEFAULT_CANVAS_WIDTH,
        int(DEFAULT_CANVAS_WIDTH / sqrt(2)),
        Margin(0, 0, 0, 0),
    )
    self._translate_x = 0
    self._translate_y = 0

translate property

translate

Returns the translation value. For instance, "translate(15, 12)" and if x and y values of the translation equal zero, it returns None.

Returns:

Type Description
str | None

Translation value

set_translate

set_translate(x=0, y=0)

Sets the translation values

Parameters:

Name Type Description Default

x

int

X translation value

0

y

int

Y translation value

0
Source code in plotynium/properties.py
def set_translate(self, x: int = 0, y: int = 0):
    """
    Sets the translation values

    Parameters
    ----------
    x : int
        X translation value
    y : int
        Y translation value
    """
    self._translate_x = x
    self._translate_y = y

plotynium.properties.LegendProperties

LegendProperties()

Legend properties which has default values for width, height and margin values.

Source code in plotynium/properties.py
def __init__(self):
    super().__init__(
        DEFAULT_LEGEND_WIDTH,
        DEFAULT_LEGEND_HEIGHT,
        Margin(
            (DEFAULT_LEGEND_HEIGHT - DEFAULT_SQUARE_SIZE // 2) // 2,
            DEFAULT_SQUARE_SIZE,
            (DEFAULT_LEGEND_HEIGHT - DEFAULT_SQUARE_SIZE // 2) // 2,
            DEFAULT_SQUARE_SIZE,
        ),
    )

new classmethod

Returns legend properties given specific values.

Parameters:

Name Type Description Default

width

int

Width value

240

height

int

Height value

50

margin_top

int

Margin top value

21

margin_left

int

Margin left value

15

margin_bottom

int

Margin bottom value

21

margin_right

int

Margin right value

15

Returns:

Type Description
LegendProperties

Legend properties filled with the given values

Source code in plotynium/properties.py
@classmethod
def new(
    self,
    width: int = 240,
    height: int = 50,
    margin_top: int = 21,
    margin_left: int = 15,
    margin_bottom: int = 21,
    margin_right: int = 15,
) -> TLegendProperties:
    """
    Returns legend properties given specific values.

    Parameters
    ----------
    width : int
        Width value
    height : int
        Height value
    margin_top : int
        Margin top value
    margin_left : int
        Margin left value
    margin_bottom : int
        Margin bottom value
    margin_right : int
        Margin right value

    Returns
    -------
    LegendProperties
        Legend properties filled with the given values
    """
    properties = LegendProperties()
    properties.set_width(width)
    properties.set_height(height)
    properties.set_margin(
        Margin(
            margin_top,
            margin_left,
            margin_bottom,
            margin_right,
        )
    )
    return properties