API

Base Classes

class ziaplot.drawable.Drawable

Drawable SVG/XML object. Implements common XML and SVG functions, plus _repr_ for Jupyter

cssclass(cls: str) Drawable

Set the CSS class name for the item. Matches items in CSS with .name selector

cssid(idn: str) Drawable

Set the CSS id for the item. Matches items in CSS with #name selector

imagebytes(fmt: Literal['svg', 'eps', 'pdf', 'png'] = 'svg') bytes

Get byte data for image

Parameters:

ext – File format extension. Will be extracted from fname if not provided.

save(fname: str)

Save image to a file

Parameters:

fname – Filename, with extension.

Notes

SVG format is always supported. EPS, PDF, and PNG formats are available when the cairosvg package is installed

span(columns: int = 1, rows: int = 1) Drawable

Set the row and column span for the item when placed in a grid layout.

svg() str

Get SVG string representation

svgxml(border: bool = False) Element

Generate XML for a standalone SVG

zorder(zorder: int = 1) Drawable

Set zorder for the drawable

class ziaplot.container.Container

Drawing container base class (either Diagrams or Layouts)

class ziaplot.element.Element

Base class for elements, defining a single object in a plot

name(name: str) Element

Sets the element name to include in the legend


Diagrams and Graphs

class ziaplot.diagrams.diagram.Diagram

Base plotting class

add(comp: Component) None

Add a component to the diagram

colorfade(*clrs: str, stops: Sequence[float] | None = None) Diagram

Define the color cycle evenly fading between multiple colors.

Parameters:
  • colors – List of colors in #FFFFFF format

  • stops – List of stop positions for each color in the gradient, starting with 0 and ending with 1.

datarange() DataRange

Get range of data only

equal_aspect() Diagram

Set equal aspect ratio on data limits

legend(loc: Literal['left', 'right', 'topleft', 'topright', 'bottomleft', 'bottomright', 'none'] = 'left') Diagram

Specify legend location

match_x(other: Diagram)

Set this diagram’s x range equal to the other diagram’s x range

match_y(other: Diagram)

Set this diagram’s y range equal to the other diagram’s y range

size(w: float = 600, h: float = 400) Diagram

Set canvas width and height

svgxml(border: bool = False) Element

XML for standalone SVG

title(title: str) Diagram

Set the title

xrange(xmin: float, xmax: float) Diagram

Set x-range of data display

yrange(ymin, ymax)

Set y-range of data display

class ziaplot.diagrams.graph.Graph

Plot of x-y data

axesnames(x: str | None = None, y: str | None = None) Diagram

Set names for the x and y axes

noxticks() Diagram

Turn off x axis tick marks

noyticks() Diagram

Turn off y axis tick marks

xticks(values: Sequence[float], names: Sequence[str] | None = None, minor: Sequence[float] | None = None) Diagram

Set x axis tick values and names

yticks(values: Sequence[float], names: Sequence[str] | None = None, minor: Sequence[float] | None = None) Diagram

Set y axis tick values and names

class ziaplot.diagrams.graph.GraphQuad

Graph showing all 4 quadrants of the coordinate plane. Axes are drawn as arrows pointing to infinity with xname and yname labels at the ends of the arrows.

datarange() DataRange

Get range of x-y data. GraphQuad datarange must include x=0 and y=0

class ziaplot.diagrams.graph.GraphQuadCentered

GraphQuad with the origin always centered

datarange() DataRange

Get range of x-y data. GraphQuad datarange must include x=0 and y=0

class ziaplot.diagrams.graphlog.GraphLogY

Plot with Y on a log10 scale

datarange() DataRange

Get range of data

class ziaplot.diagrams.graphlog.GraphLogX

Plot with Y on a log10 scale

datarange() DataRange

Get range of data

class ziaplot.diagrams.graphlog.GraphLogXY

Plot with X and Y on a log10 scale

datarange() DataRange

Get range of data only

class ziaplot.diagrams.polar.GraphPolar(labeldeg: bool = True, labeltheta: float = 0)

Polar Plot. Use with LinePolar to define lines in (radius, angle) format.

Parameters:
  • labeldeg – Draw theta labels in degrees vs. radians

  • labeltheta – Angle for drawing R labels

rrange(rmax: float) None

Sets maximum radius to display

yrange(ymin: float, ymax: float) None

Sets range of y data

class ziaplot.diagrams.smith.GraphSmith(grid: Literal['coarse', 'medium', 'fine', 'extrafine'] = 'coarse')

Smith Chart

Parameters:

grid – Smith grid spacing

class ziaplot.diagrams.ticker._Ticker

Use to generate ticks using slice notation:

Examples

ticker[0:10:1] # Generate ticks from 0 to 10 ticker[0:10:2] # Step from 0-10 by 2’s


Discrete Plot Types

class ziaplot.discrete.polylines.PolyLine(x: Sequence[float], y: Sequence[float])

A polyline of x-y data, points connected by line segments

Parameters:
  • x – X-values to plot

  • y – Y-values to plot

class ziaplot.discrete.polylines.Scatter(x: Sequence[float], y: Sequence[float])

An X-Y Scatter data

Parameters:
  • x – X-values to plot

  • y – Y-values to plot

class ziaplot.discrete.polylines.ErrorBar(x: Sequence[float], y: Sequence[float], yerr: Sequence[float] | None = None, xerr: Sequence[float] | None = None)

An X-Y PolyLine with Error Bars in X and/or Y

Parameters:
  • x – X-values to plot

  • y – Y-values to plot

  • yerr – Y errors

  • xerr – X errors

datarange() DataRange

Get range of data

class ziaplot.discrete.polylines.LineFill(x: Sequence[float], ymax: Sequence[float], ymin: Sequence[float] | None = None)

A filled line/region

Parameters:
  • x – X-values

  • ymax – Y-values defining upper limit of region

  • ymin – Y-values defining lower limit of region. Defaults to 0.

color(color: str) LineFill

Sets the edge color

datarange() DataRange

Get range of data

fill(color: str) LineFill

Set the region fill color and transparency

Parameters:

color – Fill color

class ziaplot.discrete.bars.Bars(x: Sequence[float], y: Sequence[float], y2: Sequence[float] | None = None, width: float | None = None, align: Literal['left', 'center', 'right'] = 'center')

A series of bars to add to an Graph (quantitative x values) For qualitative bar chart, use a BarChart instance.

Parameters:
  • x – X-values of each bar

  • y – Y-values of each bar

  • y2 – Minimum y-values of each bar

  • width – Width of all bars

  • align – Bar position in relation to x value

datarange()

Get x-y datarange

svgxml(border: bool = False) Element

Generate XML for standalone SVG

class ziaplot.discrete.bars.BarsHoriz(x: Sequence[float], y: Sequence[float], y2: Sequence[float] | None = None, width: float | None = None, align: Literal['left', 'center', 'right'] = 'center')

Horizontal bars

datarange() DataRange

Get x-y datarange

class ziaplot.discrete.bars.Histogram(x: Sequence[float], bins: int | None = None, binrange: tuple[float, float, float] | None = None, density: bool = False, weights: Sequence[float] | None = None)

Histogram data

Parameters:
  • x – Data to show as histogram

  • bins – Number of bins for histogram

  • binrange – Tuple of (start, stop, step) defining bins

  • density – Normalize the histogram

  • weights – Weights to apply to each x value

class ziaplot.discrete.bars.HistogramHoriz(x: Sequence[float], bins: int | None = None, binrange: tuple[float, float, float] | None = None, density: bool = False, weights: Sequence[float] | None = None)
class ziaplot.discrete.polar.LinePolar(radius: Sequence[float], theta: Sequence[float], deg: bool = False)

Define a data PolyLine using polar coordinates

Parameters:
  • radius – The radius values to plot

  • theta – The theta values to plot, in degres or radians

  • deg – Interpret theta as degrees instead of radians

class ziaplot.discrete.contour.Contour(x: Sequence[float], y: Sequence[float], z: Sequence[Sequence[float]], levels: int | Sequence[float] = 7, colorbar: Literal['top', 'right', 'bottom', 'left'] | None = None)

Contour Plot

Parameters:
  • x – 1D array of x values

  • y – 1D array of y values

  • z – 2D array of z (height) values

  • levels – Number of contour lines, or array of contour line levels

  • colorbar – Position of colorbar, top, bottom, left, or right.

colors(*colors: str, stops: Sequence[float] | None = None) Contour

Set the start and end colors for the contours

datarange() DataRange

Get range of data

get_color_steps() list[str]

Get colors for each level

property nlevels: int

Number of levels in the contour

svgxml(border: bool = False) Element

Generate XML for standalone SVG

class ziaplot.diagrams.smith.SmithConstResistance(resistance: float, xmin: float = -inf, xmax: float = inf)

Smith chart circle of constant Resistance (normalized)

Parameters:
  • resistance – Resistance value (0 to inf)

  • xmin – Minimum reactance intersection value

  • xmax – Maximum reactance intersection value

Notes

Leave xmin and xmax at inf to draw full circle

class ziaplot.diagrams.smith.SmithConstReactance(reactance: float, rmax: float = inf, rmin: float = 0)

Smith chart arcs of constant Reactance (normalized). Draws both positive and negative (capacitive and inductive) arcs.

Parameters:
  • reactance – Reactance value

  • rmax – maximum resistance intersection value

  • rmin – minimum resistance intersection value


Geometric

class ziaplot.geo.Function(func: Callable[[float], float], xrange: tuple[float, float] | None = None, n: int = 200)

Plot a function

Parameters:
  • func – Callable function of x, returning y (e.g. lambda x: x**2)

  • xmin – Minimum x value

  • xmax – Maximum x value

  • n – Number of datapoints for discrete representation

endmarkers(start: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<', end: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '>') Function

Define markers to show at the start and end of the line. Use defaults to show arrowheads pointing outward in the direction of the line.

midmarker(midmark: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<') Function

Define marker for midpoint (x/2) of Function curve

svgxml(border: bool = False) Element

Generate XML for standalone SVG

x(y: float) float

Calculate x at given y

y(x: float) float

Evaluate f(x)

class ziaplot.geo.implicit.Implicit(f: Callable, xlim: Tuple[float, float] = (-1, 1), ylim: Tuple[float, float] = (-1, 1), n: int = 100)

Plot an implicit function

Parameters:
  • f – A function of x and y, to plot f(x, y) = 0.

  • xlim – Range of data for x direction

  • ylim – Range of data for y direction

  • n – Number of data points along x and y used to estimate the plot curves

class ziaplot.geo.line.Line(point: Tuple[float, float], slope: float = 0)

A straight Line extending to infinity

Parameters:
  • point – One point on the line

  • slope – Slope of the line

endmarkers(start: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<', end: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '>') Line

Define markers to show at the start and end of the line. Use defaults to show arrowheads pointing outward in the direction of the line.

classmethod from_points(p1: Tuple[float, float], p2: Tuple[float, float]) Line

Create a line from two points

classmethod from_slopeintercept(slope: float, intercept: float = 0) Line

Create a line from slope and intercept

property homogeneous: tuple[float, float, float]

Line in homogeneous coordinates

property intercept: float

Y-intercept of Line

label(text: str, loc: float = 0, align: Literal['N', 'E', 'S', 'W', 'NE', 'NW', 'SE', 'SW'] = 'N', rotate: bool = False, color: str | None = None, size: float | None = None) Line

Add a label along the Line

Parameters:
  • text – The text to add

  • loc – Position along the line as fraction from 0-1

  • align – Text alignment

  • rotate – Rotate the text with the line

  • color – Text color

  • size – Text size

midmarker(midmark: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<') Line

Add a marker to the center of the Segment

property point2: Tuple[float, float]

Get a second point on the line, 1 unit away

x(y) float

Calculate x at y

y(x: float) float

Calculate y at x

class ziaplot.geo.line.VLine(x: float)

Vertical Line at x

class ziaplot.geo.line.HLine(y: float)

Horizontal Line at y

class ziaplot.geo.line.Segment(p1: Tuple[float, float], p2: Tuple[float, float])

Line segment from p1 to p2

datarange() DataRange

Get range of data

classmethod horizontal(p: Tuple[float, float], tox: float = 0) Segment

Create a horizontal segment from p to the tox x value

property length: float

Length of the segment

property point2: Tuple[float, float]

Second point on the segment

trim(x1: float | None = None, x2: float | None = None) Segment

Move endpoints of segment, keeping slope and intercept

classmethod vertical(p: Tuple[float, float], toy: float = 0) Segment

Create a vertical segment from p to the toy y value

class ziaplot.geo.line.Vector(x: float, y: float)

A Vector arrow from (0, 0) to (x, y)

classmethod from_angle(theta: float, d: float = 1)

Create Vector from angle and length

class ziaplot.geo.point.Point(x: float, y: float)

Point with optional text label

Parameters:
  • x – X-value

  • y – Y-value

classmethod at(f: Function, x: float) Point

Draw a Point at y = f(x)

classmethod at_intersection(f1: Function, f2: Function, x1: float | None = None, x2: float | None = None) Point

Draw a Point at the intersection of two functions

classmethod at_maximum(f: Function, x1: float, x2: float) Point

Draw a Point at local maximum of f between x1 and x2

classmethod at_minimum(f: Function, x1: float, x2: float) Point

Draw a Point at local minimum of f between x1 and x2

classmethod at_y(f: Function, y: float) Point

Draw a Point at y = f(x)

datarange() DataRange

Get x-y datarange

guidex(toy: float = 0) Point

Draw a vertical guide line between point and toy

guidey(tox: float = 0) Point

Draw a horizontal guide line between point and tox

label(text: str, pos: Literal['N', 'E', 'S', 'W', 'NE', 'NW', 'SE', 'SW'] = 'NE') Point

Add a text label to the point

Parameters:
  • text – Label

  • text_pos – Position for label with repsect to the point (N, E, S, W, NE, NW, SE, SW)

marker(marker: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None], radius: float | None = None, orient: bool = False) Point

Sets the point marker shape and size

classmethod on_circle(circle: Circle, theta: float) Point

Draw a Point on the circle at angle theta (degrees)

property point: Tuple[float, float]

XY coordinate tuple

class ziaplot.geo.bezier.BezierQuad(p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float])

Quadratic Bezier Curve

Parameters:
  • p1 – Control points for curve

  • p2 – Control points for curve

  • p3 – Control points for curve

endmarkers(start: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<', end: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '>') BezierQuad

Define markers to show at the start and end of the curve. Use defaults to show arrowheads pointing outward in the direction of the curve.

length(n: int = 50) float

Approximate length of the curve

Parameters:

n – the number of points in t used to linearly approximate the curve

midmarker(midmark: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = '<') BezierQuad

Add marker to center of curve

svgxml(border: bool = False) Element

Generate XML for standalone SVG

xy(t: float) Tuple[float, float]

Evaluate (x, y) value of curve at parameter t

class ziaplot.geo.bezier.BezierCubic(p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float], p4: Tuple[float, float])

Cubic Bezier Curve

Parameters:
  • p1 – Control points for curve

  • p2 – Control points for curve

  • p3 – Control points for curve

  • p4 – Control points for curve

xy(t: float) Tuple[float, float]

Evaluate (x, y) on curve at parameter t

class ziaplot.geo.bezier.Curve(p1: Tuple[float, float], p2: Tuple[float, float], k: float = 0.15)

Symmetric curve connecting the two points with deflection k as fraction of distance between endpoints

class ziaplot.geo.tangents.Tangent

Create Line tangent to other geometric instances

classmethod to(f: Function, x: float) Line

Create a Line tangent to f at x

classmethod to_bezier(b: BezierQuad, t: float) Line

Create a linle tangent to Bezier at parameter t

classmethod to_circle(circle: Circle, theta: float) Line

Create a Line tangent to the circle at theta (degrees)

class ziaplot.geo.tangents.TangentSegment

Create Segment tangent to other geometric instances

classmethod to(f: Function, x: float, d1: float = 1, d2: float = 1) Segment

Create a Segment tangent to f at x, extending d1 to the left and d2 to the right.

classmethod to_bezier(b: BezierQuad, t: float, d1: float = 1, d2: float = 1) Segment

Create a linle tangent to Bezier at parameter t extending d1 to the left and d2 to the right.

classmethod to_circle(circle: Ellipse, theta: float, d1: float = 1, d2: float = 1) Segment

Create a Segment tangent to the circle/ellipse at theta (degrees) extending d1 to the left and d2 to the right.

class ziaplot.geo.tangents.Normal

Create Lines normal to other geometric instances

classmethod to(f: Function, x: float) Line

Create a Line tangent to f at x

classmethod to_bezier(b: BezierQuad, t: float) Line

Create a linle normal to Bezier at parameter t

classmethod to_circle(circle: Ellipse, theta: float) Line

Create a Line tangent to the circle/ellipse at theta

class ziaplot.geo.tangents.NormalSegment

Create Segment normal to other geometric instances

classmethod to(f: Function, x: float, d1: float = 1, d2: float = 1) Segment

Create a Segment normal to f at x, extending d1 to the left and d2 to the right.

classmethod to_bezier(b: BezierQuad, t: float, d1: float = 1, d2: float = 1) Segment

Create a linle tangent to Bezier at parameter t extending d1 to the left and d2 to the right.

classmethod to_circle(circle: Ellipse, theta: float, d1: float = 1, d2: float = 1) Segment

Create a Segment normal to the circle/ellipse at theta extending d1 to the left and d2 to the right.

class ziaplot.geo.tangents.Diameter(circle: Ellipse, theta: float = 0)

Create Diameter Segment on a Circle or Ellipse at an angle of theta (degrees).

class ziaplot.geo.tangents.Secant(circle: Ellipse, theta1: float = 0, theta2: float = 180)

Create Secant Line on a Circle or Ellipse. between points on the circle with angles of theta1 and theta2 (degrees).

See also: Chord

classmethod to_bezier(b: BezierQuad, t1: float, t2: float) Line

Create a secant line on the function f

classmethod to_function(f: Function, x1: float, x2: float) Line

Create a secant line on the function f

class ziaplot.geo.tangents.Chord(circle: Ellipse, theta1: float = 0, theta2: float = 180)

Create Chord Segment on a Circle or Ellipse. between points on the circle with angles of theta1 and theta2 (degrees).

See also: Secant

classmethod to_bezier(b: BezierQuad, t1: float, t2: float) Segment

Create a secant line on the function f

classmethod to_function(f: Function, x1: float, x2: float) Segment

Create a Chord Segment on the function f

class ziaplot.geo.tangents.Sagitta(circle: Ellipse, theta1: float = 0, theta2: float = 180)

Create Sagitta Segment (perpendicular to a chord) on a Circle or Ellipse, defined by a chord between points on the circle with angles of theta1 and theta2 (degrees).

class ziaplot.geo.integral.IntegralFill(f: Function, f2: Function | None = None, x1: float | None = None, x2: float | None = None)

Fill between two functions or between a function and the x-axis

Parameters:
  • f – Function or Line instance

  • f2 – Another Function instance

  • x1 – Starting x value to fill

  • x2 – Ending x value to fill

classmethod intersection(f: Function, f2: Function, x1: float, x2: float)

Integral fill between intersection of f and f2, where x1 and x2 are points outside the intersection

class ziaplot.shapes.shapes.Circle(x: float, y: float, radius: float)

Draw a circle

Parameters:
  • x – Center x coordinate

  • y – Center y coordinate

  • radius – Radius of circle

class ziaplot.shapes.shapes.Ellipse(x: float, y: float, r1: float, r2: float, theta: float = 0)

Draw an Ellipse

Parameters:
  • x – Center x coordinate

  • y – Center y coordinate

  • r1 – Radius 1

  • r2 – Radius 2

  • theta – Angle of rotation (degrees)

datarange() DataRange

Data limits

xy(theta: float) Tuple[float, float]

Get x, y coordinate on the circle at the angle theta (degrees)

class ziaplot.shapes.shapes.Rectangle(x: float, y: float, width: float, height: float, cornerradius: float = 0)

Draw a rectangle

Parameters:
  • x – lower left x value

  • y – lower left y value

  • width – width of rectangle

  • height – height of rectangle

  • cornerradius – radius of corners


Charts

class ziaplot.charts.pie.Pie(labelmode: Literal['name', 'percent', 'value'] = 'name')

Pie Chart. Total of all wedge values will be normalized to 100%.

Parameters:

labelmode – How to label each wedge - by name, percent, or value.

classmethod fromdict(slices: dict[str, float], labelmode: PieLabelMode = 'name') Pie

Create Pie from bars dictionary

Parameters:
  • slices – dictionary of name:value pairs

  • labelmode – How to label each wedge - by name, percent, or value.

classmethod fromlist(slices: list[float], labelmode: PieLabelMode = 'name') Pie

Create Pie from list of values

Parameters:
  • slices – list of values

  • labelmode – How to label each wedge - by name, percent, or value.

class ziaplot.charts.pie.PieSlice(value: float = 1)

One slice of a pie.

Parameters:

value – value assigned to this slice. Percent will be calculated using total value of all the slices.

edgecolor(color: str) PieSlice

Sets the slice stroke/linestyle

edgewidth(width: float) PieSlice

Set the slice edge width

extrude(extrude: float = 20) PieSlice

Extrude the slice

class ziaplot.charts.bar.BarChart

A vertical bar chart with a single bar series. Independent variable is qualitative.

Note

For a bar graph with quantitative x values, use Graph and add Bars instances.

add(bar: Component) None

Add a single bar

classmethod fromdict(bars: dict[str, float]) BarChart

Create a barchart from dictionary of name: value pairs

class ziaplot.charts.bar.Bar(value: float = 1)

A single bar in a BarChart

Parameters:

value – value assigned to this bar.

class ziaplot.charts.bar.BarChartGrouped(groups: Sequence[str])

A grouped bar chart, where independent variable is qualitative.

Parameters:

groups – list of x value strings

Note

For a bar graph with quantitative x values, use Graph and add Bars instances.

add(barseries: Component) None

Add a series of bars to the chart

classmethod fromdict(bars: dict[str, Sequence[float]], groups: Sequence[str]) BarChartGrouped

Create Bar Chart from dictionary of name: values list

class ziaplot.charts.bar.BarSeries(*values: float)

A series of bars across all groups

Parameters:

values – values assigned to this bar series.


Annotations

class ziaplot.annotations.text.Text(x: float, y: float, s: str, halign: Literal['left', 'center', 'right'] = 'left', valign: Literal['top', 'center', 'baseline', 'base', 'bottom'] = 'bottom', rotate: float | None = None)

A text element to draw at a specific x-y location

Parameters:
  • x – X-position for text

  • y – Y-position for text

  • s – String to draw

  • halign – Horizontal alignment

  • valign – Vertical alignment

  • rotate – Rotation angle, in degrees

color(color: str) Text

Sets the text color

datarange() DataRange

Get x-y datarange

class ziaplot.annotations.annotations.Arrow(xy: Sequence[float], xytail: Sequence[float], marker: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] = 'arrow', tailmarker: Literal['round', 'o', 'square', 's', 'triangle', '^', 'triangled', 'v', 'larrow', '<', 'arrow', '>', '+', 'x', '-', '|', '||', '|||', 'undefined', None] | None = None)

An arrow pointing to an XY location, with optional text annotation

Parameters:
  • xy – XY position to point at

  • xytail – XY-position of arrow tail

  • s – String to draw at tail of arrow

  • strofst – XY offset between text and arrow tail

  • marker – Arrowhead marker shape

  • tailmarker – Arrowhead tail marker

label(text: str, pos: Literal['N', 'E', 'S', 'W', 'NE', 'NW', 'SE', 'SW'] = 'NE') Arrow

Add a text label to the point

Parameters:
  • text – Label

  • text_pos – Position for label with repsect to the point (N, E, S, W, NE, NW, SE, SW)

class ziaplot.annotations.annotations.Angle(line1: Line, line2: Line, quad: int = 1, arcs: int = 1)

Draw angle between two Lines/Segments

color(color: str) Angle

Sets the color of the angle arc

radius(radius: float, text_radius: float | None = None) Angle

Sets the radius of the angle arc

strokewidth(width: float) Angle

Sets the strokewidth of the angle arc

classmethod to_zero(line: Line, quad: int = 1)

Create angle between line and y=0


Layouts

class ziaplot.layout.LayoutH(*diagrams: Drawable, column_gap: float = 10, **kwargs)

Lay out Diagrams in horizontal row

Parameters:
  • diagrams – The Diagrams/Graphs to add

  • column_gap – Spacing between columns

class ziaplot.layout.LayoutV(*diagrams: Drawable, row_gap: float = 10, **kwargs)

Lay out Diagrams in vertical stack

Parameters:
  • diagrams – The Diagrams/Graphs to add

  • row_gap – Spacing between rows

class ziaplot.layout.LayoutGrid(*diagrams: Drawable, columns: int = 1, column_widths: str | None = None, row_heights: str | None = None, column_gap: float = 10, row_gap: float = 10, **kwargs)

Lay out Diagrams in a grid. Diagrams added to the layout fill the grid from left to right, adding rows as needed.

Parameters:
  • diagrams – The diagrams to add

  • columns – Number of columns

  • column_widths – String specifying widths of each column (see Note)

  • row_heights – String specifying widths of each column (see Note)

  • column_gap – Spacing between columns

  • row_gap – Spacing between rows

Notes

column_widths and row_heights specification is a similar style to a CSS grid layout. The string is space-delimited with each item either 1) a plain number representing the number of pixels 2) a percent of the whole width, 3) a number with “fr” suffix representing fractions of the whole. Examples: “25% 1fr” –> First column takes 25%, second column the remainder “200 1fr” –> First column takes 200 pixels, second column the remainder “2fr 1fr” –> First column is twice the width of second

add(diagram: Drawable)

Add a Diagram to the grid

size(w: float = 600, h: float = 400) LayoutGrid

Set canvas width and height

svgxml(border: bool = False) Element

XML for standalone SVG

class ziaplot.layout.LayoutEmpty

Empty placeholder for layout

Global Themes and CSS

ziaplot.style.themes.css(css: str) None

Set global CSS styling

ziaplot.style.themes.theme(name: str) None

Activate a theme by name. Use list_themes to see list of available theme names.

ziaplot.style.themes.theme_list() list[str]

Get a list of available themes

General Functions

ziaplot.container.save(fname: str) None

Save the current drawing to a file. Must be used within a Diagram or Layout context manager.

Parameters:

fname – Filename, with extension.

Notes

SVG format is always supported. EPS, PDF, and PNG formats are available when the cairosvg package is installed

Tools

A few calculation functions are made available to the user.

ziaplot.calcs.line_intersection(line1: Line, line2: Line) Tuple[float, float]

Find intersection between two lines. Raises ValueError if the lines do not intersect.

ziaplot.calcs.angle_of_intersection(line1: Line, line2: Line) float

Find angle between the two lines in degrees

ziaplot.calcs.y_intercept(line: Line) Tuple[float, float]

Get XY point of line’s y-intercept

ziaplot.calcs.x_intercept(line: Line) Tuple[float, float]

Get XY point of line’s x-intercept

ziaplot.calcs.func_intersection(f1: Function, f2: Function, x1: float, x2: float) Tuple[float, float]

Find intersection between two Functions (either of which may be a Line) in the interval x1 to x2. Raises ValueError if the curves do not intersect.

ziaplot.calcs.local_max(f: Function, x1: float, x2: float) Tuple[float, float]

Find local maximum of function f between x1 and x2

ziaplot.calcs.local_min(f: Function, x1: float, x2: float) Tuple[float, float]

Find local minimum of function f between x1 and x2

ziaplot.util.linspace(start: float, stop: float, num: int = 50) list[float]

Generate list of evenly spaced points