ragraph.plot.svg#

SVG shape methods.

This module contains two base classes, being the Line options for SVG shapes and a SVG mapping for the shapes themselves. You will also find several methods to obtain several basic shapes conveniently.

Module Contents#

Classes#

Line

SVG line options mapping.

SVG

SVG shape mapping.

Functions#

get_line(→ SVG)

Get straight line SVG mapping.

get_curvedline(→ SVG)

Get curved line (quadratic Bezier) SVG mapping.

get_rectangle(→ SVG)

Get a rectangle SVG mapping.

get_wedge(→ SVG)

Get a wedge SVG mapping.

class ragraph.plot.svg.Line(color: Optional[str] = None, width: Optional[int] = None, dash: Optional[str] = None)#

Bases: ragraph.generic.Mapping

SVG line options mapping.

Parameters:
  • color – Line color.

  • width – Line width in pixels.

  • dash – Dash style of the line.

_defaults#
color() str#

Line color.

width() int#

Line width in pixels.

dash() str#

Dash style of the line.

class ragraph.plot.svg.SVG(visible: Optional[bool] = None, type: Optional[str] = None, layer: Optional[str] = None, xref: Optional[str] = None, xsizemode: Optional[str] = None, xanchor: Optional[str] = None, x0: Optional[float] = None, x1: Optional[float] = None, yref: Optional[str] = None, ysizemode: Optional[str] = None, yanchor: Optional[str] = None, y0: Optional[float] = None, y1: Optional[float] = None, path: Optional[str] = None, opacity: Optional[float] = None, line: Optional[Union[Dict[str, Any], Line]] = None, fillcolor: Optional[str] = None, fillrule: Optional[str] = None, editable: Optional[bool] = None, name: Optional[str] = None, templateitemname: Optional[str] = None)#

Bases: ragraph.generic.Mapping

SVG shape mapping.

Parameters:
  • visible – Toggles shape visibility.

  • type – One of ‘circle’, ‘rect’, ‘path’ or ‘line’.

  • layer – ‘above’ draws shape above traces, ‘below’ under them.

  • xref – x coordinate axis. ‘paper’ or ‘x’, ‘x1’, ‘x2’, etc.

  • xsizemode – ‘scaled’ or ‘pixel’. Relative or absolute sizing w.r.t. axis.

  • xanchor – If sizemode is set to ‘pixel’, reference on axis to anchor shape to.

  • x0 – Starting x position.

  • x1 – Ending x position.

  • yref – y coordinate axis. ‘paper’ or ‘y’, ‘y1’, ‘y2’, etc.

  • ysizemode – ‘scaled’ or ‘pixel’. Relative or absolute sizing w.r.t. axis.

  • yanchor – If sizemode is set to ‘pixel’, reference on axis to anchor shape to.

  • y0 – Starting y position.

  • y1 – Ending y position.

  • path – For shapetype ‘path’, a valid SVG path, with data values as coordinates when referencing axis and absolute pixels with respect to anchors when the ‘pixel’ sizemode is set.

  • opacity – The opacity between 0.0 and 1.0.

  • line – Line mapping options. See Line.

  • fillcolor – Interior shape color.

  • fillrule – Determines which regions of complex paths constitute the interior. One of “evenodd” or “nonzero”.

  • editable – Whether the shape could be activated for edit or not.

  • name – Only used with templates.

  • templateitemname – Used to refer to a named item in this array in the template.

_keys#
visible() bool#

Toggles shape visibility.

type() str#

One of ‘circle’, ‘rect’, ‘path’ or ‘line’.

layer() str#

‘above’ draws shape above traces, ‘below’ under them.

xref() str#

x coordinate axis. ‘paper’ or ‘x’, ‘x1’, ‘x2’, etc.

xsizemode() str#

‘scaled’ or ‘pixel’. Relative or absolute sizing w.r.t. axis.

xanchor() str#

If sizemode is set to ‘pixel’, reference on axis to anchor shape to.

x0() float#

Starting x position.

x1() float#

Ending x position.

yref() str#

y coordinate axis. ‘paper’ or ‘y’, ‘y1’, ‘y2’, etc.

ysizemode() str#

‘scaled’ or ‘pixel’. Relative or absolute sizing w.r.t. axis.

yanchor() str#

If sizemode is set to ‘pixel’, reference on axis to anchor shape to.

y0() float#

Starting y position.

y1() float#

Ending y position.

path() str#

For shapetype ‘path’, a valid SVG path, with data values as coordinates when referencing axis and absolute pixels with respect to anchors when the ‘pixel’ sizemode is set.

opacity() float#

The opacity between 0.0 and 1.0.

line() Line#

Line mapping options. See Line.

fillcolor() str#

Interior shape color.

fillrule() str#

Determines which regions of complex paths constitute the interior. One of ‘evenodd’ or ‘nonzero’.

editable() bool#

Whether the shape could be activated for edit or not.

name() str#

Only used with templates.

templateitemname() str#

Used to refer to a named item in this array in the template.

ragraph.plot.svg.get_line(x0: float, x1: float, y0: float, y1: float, **kwargs) SVG#

Get straight line SVG mapping.

Parameters:
  • x0 – Starting x position.

  • x1 – Ending x position.

  • y0 – Starting y position.

  • y1 – Ending y position.

:keyword Overrides for the SVG object.:

Returns:

SVG shape mapping.

ragraph.plot.svg.get_curvedline(x0: float, x1: float, x2: float, y0: float, y1: float, y2: float, **kwargs) SVG#

Get curved line (quadratic Bezier) SVG mapping.

Parameters:
  • x0 – Starting x position.

  • x1 – Control point x position.

  • x2 – Ending x position.

  • y0 – Starting y position.

  • y1 – Control point y position.

  • y2 – Ending y position.

:keyword Overrides for the SVG object.:

Returns:

Quadratic Bezier SVG shape mapping.

ragraph.plot.svg.get_rectangle(x0: float, x1: float, y0: float, y1: float, **kwargs) SVG#

Get a rectangle SVG mapping.

Parameters:
  • x0 – Starting x position.

  • x1 – Ending x position.

  • y0 – Starting y position.

  • y1 – Ending y position.

:keyword Overrides for the SVG object.:

Returns:

SVG shape mapping.

ragraph.plot.svg.get_wedge(x: float, y: float, r: float, start_angle: float, end_angle: float, **kwargs) SVG#

Get a wedge SVG mapping.

Parameters:
  • x – x position of the wedge center.

  • y – y position of the wedge center.

  • r – radius of the wedge.

  • start_angle – Starting angle (radians) of the wedge.

  • end_angle – Ending angle (radians) of the wedge.

:keyword Overrides for the SVG object.:

Returns:

SVG shape mapping.