API

Drawable

Most Ziaplot classes inherit from Drawable, allowing them to be drawn as SVG, saved to file, or converted to other image formats.

class ziaplot.drawable.Drawable

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

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

svg()str

Get SVG string representation

svgxml(border: bool = False)xml.etree.ElementTree.Element

Generate XML for a standalone SVG

Axes

class ziaplot.axes.BasePlot(title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Base plotting class

Parameters
  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

add(series: ziaplot.series.Series)None

Add a data series to the axis

colorfade(c1: str, c2: str)None

Define the color cycle evenly fading between two colors. c1 will always be the color of the first series, and c2 the color of the last series, with an even gradient for series in between.

Parameters
  • c1 – Starting color

  • c2 – Ending color

datarange()ziaplot.canvas.DataRange

Get range of data only

svgxml(border: bool = False)xml.etree.ElementTree.Element

XML for standalone SVG

xrange(xmin: float, xmax: float)ziaplot.axes.BasePlot

Set x-range of data display

xticks(values: Sequence[float], names: Optional[Sequence[str]] = None, minor: Optional[Sequence[float]] = None)ziaplot.axes.BasePlot

Set x axis tick values and names

yrange(ymin, ymax)

Set y-range of data display

yticks(values: Sequence[float], names: Optional[Sequence[str]] = None, minor: Optional[Sequence[float]] = None)ziaplot.axes.BasePlot

Set y axis tick values and names

class ziaplot.axes.XyPlot(title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Plot of x-y data

Parameters
  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

class ziaplot.axes.XyGraph(centerorigin: bool = True, title: Optional[str] = None, xname: str = 'x', yname: str = 'y', legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

X-Y Graph. Axes are drawn as arrows pointing to infinity with xname and yname labels at the ends of the arrows. Often used to visualize functions (e.g. y = x**2) rather than empirical data.

Parameters
  • centerorigin – Place the (0, 0) origin in the center of the axis

  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

datarange()ziaplot.canvas.DataRange

Get range of x-y data. XyGraph datarange must include 0

class ziaplot.axeslog.LogYPlot(title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Plot with Y on a log10 scale

Parameters
  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

datarange()ziaplot.canvas.DataRange

Get range of data

class ziaplot.axeslog.LogXPlot(title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Plot with Y on a log10 scale

Parameters
  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

datarange()ziaplot.canvas.DataRange

Get range of data

class ziaplot.axeslog.LogXYPlot(title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Plot with X and Y on a log10 scale

Parameters
  • title – Title to draw above axes

  • xname – Name/label for x axis

  • yname – Name/label for y axis

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

datarange()ziaplot.canvas.DataRange

Get range of data only

class ziaplot.polar.Polar(labeldeg: bool = True, title: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

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

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

  • title – Title to draw above axes

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

rrange(rmax: float)None

Sets maximum radius to display

svgxml(border: bool = False)xml.etree.ElementTree.Element

XML for standalone SVG

yrange(ymin: float, ymax: float)None

Sets range of y data

class ziaplot.smith.Smith(grid: str = 'coarse', title: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

Smith Chart Axis

Parameters
  • grid – Smith grid spacing

  • title – Title to draw above axes

  • legend – Location of legend

  • style – Drawing style

style

Drawing style

svgxml(border: bool = False)xml.etree.ElementTree.Element

XML for standalone SVG

class ziaplot.pie.Pie(title: Optional[str] = None, labels: Literal[name, percent, value, None] = 'name', legend: Optional[str] = None, style: Optional[ziaplot.styletypes.Style] = None)

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

Parameters
  • title – Title of the chart

  • labels – How to label each wedge

  • legend – Location for legend

  • style – Plotting style

colorfade(c1: str, c2: str)None

Define the color cycle evenly fading between two colors. c1 will always be the color of the first series, and c2 the color of the last series, with an even gradient for series in between.

Parameters
  • c1 – Starting color

  • c2 – Ending color

names(*names: str)ziaplot.pie.Pie

Define names of each wedge added by wedges method.

svgxml(border: bool = False)xml.etree.ElementTree.Element

XML for standalone SVG

wedge(value: float, name: str = '', color: Optional[str] = None, strokecolor: Optional[str] = None, strokewidth: Optional[float] = None, extrude: bool = False)ziaplot.pie.Pie

Add a wedge to the pie.

Parameters
  • value – The value for this wedge. Total value will be normalized to 100%.

  • name – Name for the wedge to include in legend

  • color – Color for the wedge

  • strokecolor – Color for the wedge border

  • strokewidth – Line width of the wedge border

  • extrude – Show the wedge pulled out from the pie

wedges(*values: float)ziaplot.pie.Pie

Add multiple wedges to the pie

class ziaplot.bar.BarChart(xvalues: Sequence[str], horiz: bool = False, title: Optional[str] = None, xname: Optional[str] = None, yname: Optional[str] = None, legend: Literal[left, right] = 'left', style: Optional[ziaplot.styletypes.Style] = None)

A bar chart, where independent variable is qualitative.

Parameters
  • xvalues – list of x value strings

  • horiz – Draw as horizontal bars (x values will be drawn along vertical axis)

  • title – Title for chart

  • xname – Name/label for x (independent variable) axis

  • yname – Name/label for y (dependent variable) axis

  • legend – Location for legend

  • style – Plotting style

Note

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

bar(values: Sequence[float])ziaplot.dataseries.Bars

Add a set of bars to the chart

Parameters

values – Values for each bar of this series

Data Series

class ziaplot.series.Series

Base class for data series, defining a single line in a plot

color(color: str)ziaplot.series.Series

Sets the series color

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

Sets the series marker

name(name: str)ziaplot.series.Series

Sets the series name to include in the legend

stroke(stroke: Union[Literal[-, :, dotted, --, dashed, -., .-, dashdot], str])ziaplot.series.Series

Sets the series stroke/linestyle

strokewidth(width: float)ziaplot.series.Series

Sets the series strokewidth

class ziaplot.dataseries.Line(x: Sequence[float], y: Sequence[float])

A line series of x-y data

Parameters
  • x – X-values to plot

  • y – Y-values to plot

datarange()ziaplot.canvas.DataRange

Get range of data

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.

svgxml(border: bool = False)xml.etree.ElementTree.Element

Generate XML for standalone SVG

class ziaplot.dataseries.Xy(x: Sequence[float], y: Sequence[float])

An X-Y Scatter series of data

Parameters
  • x – X-values to plot

  • y – Y-values to plot

class ziaplot.dataseries.Function(func: Callable[[float], float], xmin: float = - 5, xmax: float = 5, n: int = 200)

Plot a function

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

  • xmin – Minimum x value

  • xmax – Maximum x value

  • n – Number of datapoints for discrete representation

class ziaplot.dataseries.ErrorBar(x: Sequence[float], y: Sequence[float], yerr: Optional[Sequence[float]] = None, xerr: Optional[Sequence[float]] = None)

An X-Y Line 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()ziaplot.canvas.DataRange

Get range of data

xerrmarker(marker: Literal[round, o, square, s, triangle, ^, triangled, v, larrow, <, arrow, >, +, x, -, |, undefined, None] = '|', length: Optional[float] = None, width: Optional[float] = None, stroke: Optional[Union[Literal[-, :, dotted, --, dashed, -., .-, dashdot], str]] = None)ErrorBar

Set marker and linestyle for x-error bars

Parameters
  • marker – Shape of the marker

  • length – Length of the marker

  • width – Linewidth of the marker

  • stroke – Stroke/dash style for the errorbar line

yerrmarker(marker: Literal[round, o, square, s, triangle, ^, triangled, v, larrow, <, arrow, >, +, x, -, |, undefined, None] = '-', length: Optional[float] = None, width: Optional[float] = None, stroke: Optional[Union[Literal[-, :, dotted, --, dashed, -., .-, dashdot], str]] = None)ErrorBar

Set marker and linestyle for y-error bars

Parameters
  • marker – Shape of the marker

  • length – Length of the marker

  • width – Linewidth of the marker

  • stroke – Stroke/dash style for the errorbar line

class ziaplot.dataseries.LineFill(x: Sequence[float], ymax: Sequence[float], ymin: Optional[Sequence[float]] = 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.

datarange()ziaplot.canvas.DataRange

Get range of data

fill(color: str, alpha: Optional[float] = None)LineFill

Set the region fill color and transparency

Parameters
  • color – Fill color

  • alpha – Transparency (0-1, with 1 being opaque)

svgxml(border: bool = False)xml.etree.ElementTree.Element

Generate XML for standalone SVG

class ziaplot.dataseries.Text(x: float, y: float, s: str, halign: Literal[left, center, right] = 'left', valign: Literal[top, center, bottom] = 'bottom', rotate: Optional[float] = 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()ziaplot.canvas.DataRange

Get x-y datarange

class ziaplot.dataseries.Arrow(xy: Sequence[float], xytail: Sequence[float], s: str = '', strofst: Sequence[float] = (0, 0), marker: Literal[round, o, square, s, triangle, ^, triangled, v, larrow, <, arrow, >, +, x, -, |, undefined, None] = 'arrow', tailmarker: Optional[Literal[round, o, square, s, triangle, ^, triangled, v, larrow, <, arrow, >, +, x, -, |, undefined, 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

class ziaplot.dataseries.HLine(y: float)

Horizontal line spanning the plot

Parameters

y – Y-value of the line

datarange()ziaplot.canvas.DataRange

Get x-y datarange

class ziaplot.dataseries.VLine(x: float)

Vertical line spanning the plot

Parameters

x – X-value of the line

datarange()ziaplot.canvas.DataRange

Get x-y datarange

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

A series of bars to add to an XyPlot (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)xml.etree.ElementTree.Element

Generate XML for standalone SVG

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

Horizontal bars

datarange()ziaplot.canvas.DataRange

Get x-y datarange

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

Histogram data series

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.polar.LinePolar(radius: Sequence[float], theta: Sequence[float], deg: bool = False)

Define a data Line series 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.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.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

Layouts

class ziaplot.layout.Hlayout(*axes: ziaplot.drawable.Drawable, width: float = 600, height: float = 400, sep: float = 10)

Horizontal Plot Layout

Parameters
  • axes – The axes and/or VLayouts to draw, evenly spaced horizontally

  • width – Width of the figure/layout

  • height – Height of the figure/layout

  • sep – Distance between subplots

Note

height and width are ignored if the layout is added to another layout.

class ziaplot.layout.Vlayout(*axes: ziaplot.drawable.Drawable, width: float = 600, height: float = 400, sep: float = 10)

Vertical Plot Layout

Parameters
  • axes – The axes and/or HLayouts to draw, evenly spaced vertically

  • width – Width of the figure/layout

  • height – Height of the figure/layout

  • sep – Distance between subplots

Note

height and width are ignored if the layout is added to another layout.