API¶
Base Classes¶
- class ziaplot.drawable.Drawable¶
Drawable SVG/XML object. Implements common XML and SVG functions, plus _repr_ for Jupyter
- cls(cls)¶
Set the CSS class name for the item. Matches items in CSS with .name selector
- Return type:
- cssid(idn)¶
Set the CSS id for the item. Matches items in CSS with #name selector
- Return type:
- imagebytes(fmt='svg')¶
Get byte data for image
- Parameters:
ext – File format extension. Will be extracted from fname if not provided.
- Return type:
bytes
- save(fname)¶
Save image to a file
- Parameters:
fname (
str) – Filename, with extension.
Notes
SVG format is always supported. EPS, PDF, and PNG formats are available when the cairosvg package is installed
- span(columns=1, rows=1)¶
Set the row and column span for the item when placed in a grid layout.
- Return type:
- svgxml(border=False)¶
Generate XML for a standalone SVG
- Return type:
Element
- tosvg()¶
Get SVG string representation
- Return type:
str
- 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
Diagrams and Graphs¶
- class ziaplot.diagrams.diagram.Diagram¶
Base plotting class
- add(comp)¶
Add a component to the diagram
- Return type:
None
- colorfade(*clrs, stops=None)¶
Define the color cycle evenly fading between multiple colors.
- Parameters:
colors – List of colors in #FFFFFF format
stops (
Optional[Sequence[float]]) – List of stop positions for each color in the gradient, starting with 0 and ending with 1.
- Return type:
- datarange()¶
Get range of data only
- Return type:
DataRange
- erase(*comp)¶
Erase a previously added component
- Return type:
None
- match_x(other)¶
Set this diagram’s x range equal to the other diagram’s x range
- match_y(other)¶
Set this diagram’s y range equal to the other diagram’s y range
- svgxml(border=False)¶
XML for standalone SVG
- Return type:
Element
- yrange(ymin, ymax)¶
Set y-range of data display
- class ziaplot.diagrams.graph.Graph¶
Plot of x-y data
- 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()¶
Get range of x-y data. GraphQuad datarange must include x=0 and y=0
- Return type:
DataRange
- class ziaplot.diagrams.graph.GraphQuadCentered¶
GraphQuad with the origin always centered
- datarange()¶
Get range of x-y data. GraphQuad datarange must include x=0 and y=0
- Return type:
DataRange
- class ziaplot.diagrams.graphlog.GraphLogY¶
Plot with Y on a log10 scale
- datarange()¶
Get range of data
- Return type:
DataRange
- class ziaplot.diagrams.graphlog.GraphLogX¶
Plot with Y on a log10 scale
- datarange()¶
Get range of data
- Return type:
DataRange
- class ziaplot.diagrams.graphlog.GraphLogXY¶
Plot with X and Y on a log10 scale
- datarange()¶
Get range of data only
- Return type:
DataRange
- class ziaplot.diagrams.polar.GraphPolar(labeldeg=True, labeltheta=0)¶
Polar Plot. Use with LinePolar to define lines in (radius, angle) format.
- Parameters:
labeldeg (
bool) – Draw theta labels in degrees vs. radianslabeltheta (
float) – Angle for drawing R labels
- rrange(rmax)¶
Sets maximum radius to display
- Return type:
None
- yrange(ymin, ymax)¶
Sets range of y data
- Return type:
None
- class ziaplot.diagrams.smith.GraphSmith(grid='coarse')¶
Smith Chart
- Parameters:
grid (
Literal['coarse','medium','fine','extrafine']) – 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, y)¶
A polyline of x-y data, points connected by line segments
- Parameters:
x (
Sequence[float]) – X-values to ploty (
Sequence[float]) – Y-values to plot
- class ziaplot.discrete.polylines.Scatter(x, y)¶
An X-Y Scatter data
- Parameters:
x (
Sequence[float]) – X-values to ploty (
Sequence[float]) – Y-values to plot
- class ziaplot.discrete.polylines.ErrorBar(x, y, yerr=None, xerr=None)¶
An X-Y PolyLine with Error Bars in X and/or Y
- Parameters:
x (
Sequence[float]) – X-values to ploty (
Sequence[float]) – Y-values to plotyerr (
Optional[Sequence[float]]) – Y errorsxerr (
Optional[Sequence[float]]) – X errors
- datarange()¶
Get range of data
- Return type:
DataRange
- class ziaplot.discrete.polylines.LineFill(x, ymax, ymin=None)¶
A filled line/region
- Parameters:
x (
Sequence[float]) – X-valuesymax (
Sequence[float]) – Y-values defining upper limit of regionymin (
Optional[Sequence[float]]) – Y-values defining lower limit of region. Defaults to 0.
- datarange()¶
Get range of data
- Return type:
DataRange
- class ziaplot.discrete.bars.Bars(x, y, y2=None, width=None, align='center')¶
A series of bars to add to an Graph (quantitative x values) For qualitative bar chart, use a BarChart instance.
- Parameters:
x (
Sequence[float]) – X-values of each bary (
Sequence[float]) – Y-values of each bary2 (
Optional[Sequence[float]]) – Minimum y-values of each barwidth (
Optional[float]) – Width of all barsalign (
Literal['left','center','right']) – Bar position in relation to x value
- datarange()¶
Get x-y datarange
- svgxml(border=False)¶
Generate XML for standalone SVG
- Return type:
Element
- class ziaplot.discrete.bars.BarsHoriz(x, y, y2=None, width=None, align='center')¶
Horizontal bars
- datarange()¶
Get x-y datarange
- Return type:
DataRange
- class ziaplot.discrete.bars.Histogram(x, bins=None, binrange=None, density=False, weights=None)¶
Histogram data
- Parameters:
x (
Sequence[float]) – Data to show as histogrambins (
Optional[int]) – Number of bins for histogrambinrange (
Optional[tuple[float,float,float]]) – Tuple of (start, stop, step) defining binsdensity (
bool) – Normalize the histogramweights (
Optional[Sequence[float]]) – Weights to apply to each x value
- class ziaplot.discrete.bars.HistogramHoriz(x, bins=None, binrange=None, density=False, weights=None)¶
- class ziaplot.discrete.polar.LinePolar(radius, theta, deg=False)¶
Define a data PolyLine using polar coordinates
- Parameters:
radius (
Sequence[float]) – The radius values to plottheta (
Sequence[float]) – The theta values to plot, in degres or radiansdeg (
bool) – Interpret theta as degrees instead of radians
- class ziaplot.discrete.contour.Contour(x, y, z, levels=7, colorbar=None)¶
Contour Plot
- Parameters:
x (
Sequence[float]) – 1D array of x valuesy (
Sequence[float]) – 1D array of y valuesz (
Sequence[Sequence[float]]) – 2D array of z (height) valueslevels (
Union[int,Sequence[float]]) – Number of contour lines, or array of contour line levelscolorbar (
Optional[Literal['top','right','bottom','left']]) – Position of colorbar, top, bottom, left, or right.
- datarange()¶
Get range of data
- Return type:
DataRange
- get_color_steps()¶
Get colors for each level
- Return type:
list[str]
- property nlevels: int¶
Number of levels in the contour
- svgxml(border=False)¶
Generate XML for standalone SVG
- Return type:
Element
- class ziaplot.diagrams.smith.SmithConstResistance(resistance, xmin=-inf, xmax=inf)¶
Smith chart circle of constant Resistance (normalized)
- Parameters:
resistance (
float) – Resistance value (0 to inf)xmin (
float) – Minimum reactance intersection valuexmax (
float) – Maximum reactance intersection value
Notes
Leave xmin and xmax at inf to draw full circle
- class ziaplot.diagrams.smith.SmithConstReactance(reactance, rmax=inf, rmin=0)¶
Smith chart arcs of constant Reactance (normalized). Draws both positive and negative (capacitive and inductive) arcs.
- Parameters:
reactance (
float) – Reactance valuermax (
float) – maximum resistance intersection valuermin (
float) – minimum resistance intersection value
Geometric Figures¶
- class ziaplot.figures.function.Function(func, xrange=None, n=200)¶
Plot a function
- Parameters:
func (
Callable[[float],float]) – Callable function of x, returning y (e.g. lambda x: x**2)xmin – Minimum x value
xmax – Maximum x value
n (
int) – Number of datapoints for discrete representation
- endmarkers(start='<', end='>')¶
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.
- Return type:
- svgxml(border=False)¶
Generate XML for standalone SVG
- Return type:
Element
- x(y)¶
Calculate x at given y
- Return type:
float
- xy(x)¶
Calculate (x, y) on function at x
- Return type:
Tuple[float,float]
- y(x)¶
Evaluate f(x)
- Return type:
float
- class ziaplot.figures.implicit.Implicit(f, xlim=(-1, 1), ylim=(-1, 1), n=100)¶
Plot an implicit function
- Parameters:
f (
Callable) – A function of x and y, to plot f(x, y) = 0.xlim (
Tuple[float,float]) – Range of data for x directionylim (
Tuple[float,float]) – Range of data for y directionn (
int) – Number of data points along x and y used to estimate the plot curves
- class ziaplot.figures.line.Line(point, slope=0)¶
A straight Line extending to infinity
- Parameters:
point (
Union[Tuple[float,float],Point]) – One point on the lineslope (
float) – Slope of the line
- bisect_angle(other, which='+')¶
Create new line bisecting the two Lines.
The which parameter specifies which of the two bisectors to return. It may be + to return the bisector with positive or 0 slope, or - to return the bisector with negative or vertical slope.
- Return type:
- endmarkers(start='<', end='>')¶
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.
- Return type:
- classmethod from_slopeintercept(slope, intercept=0)¶
Create a line from slope and intercept
- Return type:
- property intercept: float¶
Y-intercept of Line
- label(text, loc=0, align='N', rotate=False, color=None, size=None)¶
Add a label along the Line
- Parameters:
text (
str) – The text to addloc (
float) – Position along the line as fraction from 0-1align (
Literal['N','E','S','W','NE','NW','SE','SW']) – Text alignmentrotate (
bool) – Rotate the text with the linecolor (
Optional[str]) – Text colorsize (
Optional[float]) – Text size
- Return type:
- property point2: Tuple[float, float]¶
Get a second point on the line, 1 unit away
- property standard: tuple[float, float, float]¶
Line coefficients (A, B, C) in standard form Ax + By = C
- svgxml(border=False)¶
Generate XML for standalone SVG
- Return type:
Element
- trimd(x, d1, d2)¶
Covnvert the line into a segment extending a distance d1 left and d2 right of point x on the line
- Return type:
- x(y)¶
Calculate x at y
- Return type:
float
- xy(x)¶
Calculate y at x, returning point (x, y)
- Return type:
Tuple[float,float]
- y(x)¶
Calculate y at x
- Return type:
float
- class ziaplot.figures.line.VLine(x)¶
Vertical Line at x
- class ziaplot.figures.line.HLine(y)¶
Horizontal Line at y
- class ziaplot.figures.line.Segment(p1, p2)¶
Line segment from p1 to p2
- datarange()¶
Get range of data
- Return type:
DataRange
- classmethod horizontal(p, tox=0)¶
Create a horizontal segment from p to the tox x value
- Return type:
- property length: float¶
Length of the segment
- midpoint()¶
Midpoint of the segment
- Return type:
Tuple[float,float]
- property point2: Tuple[float, float]¶
Second point on the segment
- class ziaplot.figures.line.Vector(x, y)¶
A Vector arrow from (0, 0) to (x, y)
- classmethod from_angle(theta, d=1)¶
Create Vector from angle and length
- class ziaplot.figures.point.Point(p)¶
Point with optional text label
- Parameters:
p (
Tuple[float,float]) – x, y tuple
- classmethod at_intersection(f1, f2, bounds=None, which='top', offarc=False)¶
Draw a Point at the intersection of two functions, lines, circles, or arcs.
- Parameters:
bounds (
Optional[tuple[float,float]]) – tuple of x values to bound the search. Only used for intersection of two Functionswhich (
str) – in cases where more than one intersection occurs, return the top, bottom, left or right-most point.
- Return type:
- classmethod at_maximum(f, x1, x2)¶
Draw a Point at local maximum of f between x1 and x2
- Return type:
- classmethod at_midpoint(a, b)¶
Draw a point at the midpoint between the two given points
- Return type:
- classmethod at_minimum(f, x1, x2)¶
Draw a Point at local minimum of f between x1 and x2
- Return type:
- datarange()¶
Get x-y datarange
- Return type:
DataRange
- image(line)¶
Create a new point imaged onto the line (point on line at shortest distance to point)
- Return type:
- label(text, pos='NE')¶
Add a text label to the point
- Parameters:
text (
str) – Labeltext_pos – Position for label with repsect to the point (N, E, S, W, NE, NW, SE, SW)
- Return type:
- classmethod on_circle(circle, theta)¶
Draw a Point on the circle at angle theta (degrees)
- Return type:
- property point: Tuple[float, float]¶
XY coordinate tuple
- class ziaplot.figures.bezier.Bezier(p1, p2, p3, p4=None)¶
Quadratic or Cubic Bezier Curve
- Parameters:
p1 (
Tuple[float,float]) – Control points for curve. p4 Optional.p2 (
Tuple[float,float]) – Control points for curve. p4 Optional.p3 (
Tuple[float,float]) – Control points for curve. p4 Optional.p4 (
Optional[Tuple[float,float]]) – Control points for curve. p4 Optional.
- endmarkers(start='<', end='>')¶
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.
- Return type:
- svgxml(border=False)¶
Generate XML for standalone SVG
- Return type:
Element
- xy(t)¶
Evaluate (x, y) value of curve at parameter t
- Return type:
Tuple[float,float]
- class ziaplot.figures.bezier.Curve(p1, p2, k=0.15)¶
Symmetric curve connecting the two points with deflection k as fraction of distance between endpoints
- class ziaplot.figures.bezier.CurveThreePoint(start, end, mid, t=0.5)¶
Bezier Curve passing through three points and parameter t
- class ziaplot.figures.integral.IntegralFill(f, f2=None, x1=None, x2=None)¶
Fill between two functions or between a function and the x-axis
- Parameters:
- classmethod intersection(f, f2, x1, x2)¶
Integral fill between intersection of f and f2, where x1 and x2 are points outside the intersection
- class ziaplot.figures.shapes.Circle(center, radius)¶
Draw a circle
- Parameters:
x – Center x coordinate
y – Center y coordinate
radius (
float) – Radius of circle
- chord(angle1=0, angle2=180)¶
Create a chord on the circle connecting the two angles (degrees)
- Return type:
- datarange()¶
Data limits
- Return type:
DataRange
- diameter_line(angle=0)¶
Create a new Line through a diameter at the angle (degrees)
- Return type:
- diameter_segment(angle=0)¶
Create a new Segment through a diameter at the angle (degrees)
- Return type:
- classmethod from_lll(line1, line2, line3, which='top')¶
Create a circle tangent to all three lines.
The which paremeter specifies which of the 4 possible solutions to return, based on its center point. Options: :rtype:
Circletop: return the circle with the top-most center
bottom: return the circle with the bottom-most center
left: return the circle with the left-most center
right: return the circle with the right-most center
y0, y1, y2, y3: sort the circles by y value and return the Nth
x0, x1, x2, x3: sort the circles by x value and return the Nth
- classmethod from_ppp(p1, p2, p3)¶
Create a circle passing through the three given points
- Return type:
- on_arc_point(p)¶
Is the angle theta (in degrees) on the circle
- Return type:
bool
- radius_segment(angle=0)¶
Create a new Segment through a radius at the angle (degrees)
- Return type:
- sagitta(angle1=0, angle2=180)¶
Create a sagitta segment (perpendicular to the chord) on a circle defined by the chord with endpoints at angle1 and angle2.
- Return type:
- secant(angle1=0, angle2=180)¶
Create a secant on the circle through the two angles (degrees)
- Return type:
- tangent(p, which='top')¶
Create a tangent line passing through p.
- Parameters:
p (
Tuple[float,float]) – Point the tangent passees through, on or outside the circlewhich (
str) – Determines which of the two possible tangents to return. may be top, bottom, left, or right based on the position ot the tangent point on the circle.
- Return type:
- property x: float¶
Center X value
- xy(theta)¶
Get x, y coordinate on the circle at the angle theta (degrees)
- Return type:
Tuple[float,float]
- property y: float¶
Center Y value
- class ziaplot.figures.shapes.Ellipse(center, r1, r2, theta=0)¶
Draw an Ellipse
- Parameters:
x – Center x coordinate
y – Center y coordinate
r1 (
float) – Radius 1r2 (
float) – Radius 2theta (
float) – Angle of rotation (degrees)
- datarange()¶
Data limits
- Return type:
DataRange
- tangent(p, which='top')¶
Create a tangent line passing through p.
- xy(theta)¶
Get x, y coordinate on the circle at the angle theta (degrees)
- Return type:
Tuple[float,float]
- class ziaplot.figures.shapes.Rectangle(x, y, width, height, cornerradius=0)¶
Draw a rectangle
- Parameters:
x (
float) – lower left x valuey (
float) – lower left y valuewidth (
float) – width of rectangleheight (
float) – height of rectanglecornerradius (
float) – radius of corners
Charts¶
- class ziaplot.charts.pie.Pie(labelmode='name')¶
Pie Chart. Total of all wedge values will be normalized to 100%.
- Parameters:
labelmode (
Literal['name','percent','value']) – How to label each wedge - by name, percent, or value.
- classmethod fromdict(slices, labelmode='name')¶
Create Pie from bars dictionary
- Parameters:
slices (
dict[str,float]) – dictionary of name:value pairslabelmode (
Literal['name','percent','value']) – How to label each wedge - by name, percent, or value.
- Return type:
- class ziaplot.charts.pie.PieSlice(value=1)¶
One slice of a pie.
- Parameters:
value (
float) – value assigned to this slice. Percent will be calculated using total value of all the slices.
- 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)¶
Add a single bar
- Return type:
None
- class ziaplot.charts.bar.Bar(value=1)¶
A single bar in a BarChart
- Parameters:
value (
float) – value assigned to this bar.
- class ziaplot.charts.bar.BarChartGrouped(groups)¶
A grouped bar chart, where independent variable is qualitative.
- Parameters:
groups (
Sequence[str]) – list of x value strings
Note
For a bar graph with quantitative x values, use Graph and add Bars instances.
- add(barseries)¶
Add a series of bars to the chart
- Return type:
None
- classmethod fromdict(bars, groups)¶
Create Bar Chart from dictionary of name: values list
- Return type:
- class ziaplot.charts.bar.BarSeries(*values)¶
A series of bars across all groups
- Parameters:
values (
float) – values assigned to this bar series.
Annotations¶
- class ziaplot.annotations.text.Text(x, y, s, halign='left', valign='bottom', rotate=None)¶
A text element to draw at a specific x-y location
- Parameters:
x (
float) – X-position for texty (
float) – Y-position for texts (
str) – String to drawhalign (
Literal['left','center','right']) – Horizontal alignmentvalign (
Literal['top','center','baseline','base','bottom']) – Vertical alignmentrotate (
Optional[float]) – Rotation angle, in degrees
- datarange()¶
Get x-y datarange
- Return type:
DataRange
- class ziaplot.annotations.annotations.Arrow(xy, xytail, marker='arrow', tailmarker=None)¶
An arrow pointing to an XY location, with optional text annotation
- Parameters:
xy (
Sequence[float]) – XY position to point atxytail (
Sequence[float]) – XY-position of arrow tails – String to draw at tail of arrow
strofst – XY offset between text and arrow tail
marker (
Literal['round','o','square','s','triangle','^','triangled','v','larrow','<','arrow','>','+','x','-','|','||','|||','undefined',None]) – Arrowhead marker shapetailmarker (
Optional[Literal['round','o','square','s','triangle','^','triangled','v','larrow','<','arrow','>','+','x','-','|','||','|||','undefined',None]]) – Arrowhead tail marker
- class ziaplot.annotations.annotations.Angle(line1, line2, quad=1, arcs=1)¶
Draw angle between two Lines/Segments
- classmethod to_zero(line, quad=1)¶
Create angle between line and y=0
Layouts¶
- class ziaplot.layout.LayoutH(*diagrams, column_gap=10, **kwargs)¶
Lay out Diagrams in horizontal row
- Parameters:
diagrams (
Drawable) – The Diagrams/Graphs to addcolumn_gap (
float) – Spacing between columns
- class ziaplot.layout.LayoutV(*diagrams, row_gap=10, **kwargs)¶
Lay out Diagrams in vertical stack
- Parameters:
diagrams (
Drawable) – The Diagrams/Graphs to addrow_gap (
float) – Spacing between rows
- class ziaplot.layout.LayoutGrid(*diagrams, columns=1, column_widths=None, row_heights=None, column_gap=10, row_gap=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 (
Drawable) – The diagrams to addcolumns (
int) – Number of columnscolumn_widths (
Optional[str]) – String specifying widths of each column (see Note)row_heights (
Optional[str]) – String specifying widths of each column (see Note)column_gap (
float) – Spacing between columnsrow_gap (
float) – 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)¶
Add a Diagram to the grid
- size(w=600, h=400)¶
Set canvas width and height
- Return type:
- svgxml(border=False)¶
XML for standalone SVG
- Return type:
Element
- class ziaplot.layout.LayoutEmpty¶
Empty placeholder for layout
Global Themes and CSS¶
- ziaplot.style.themes.css(css)¶
Set global CSS styling
- Return type:
None
- ziaplot.style.themes.theme(name)¶
Activate a theme by name. Use list_themes to see list of available theme names.
- Return type:
None
- ziaplot.style.themes.theme_list()¶
Get a list of available themes
- Return type:
list[str]
General Functions¶
- ziaplot.container.save(fname)¶
Save the current drawing to a file. Must be used within a Diagram or Layout context manager.
- Parameters:
fname (
str) – Filename, with extension.- Return type:
None
Notes
SVG format is always supported. EPS, PDF, and PNG formats are available when the cairosvg package is installed
- class ziaplot.attributes.Attributes¶
Access attributes and subelements of the SVG element
- get(name, default=None)¶
Get an SVG attribute from the element
- Parameters:
name (
str) – The SVG/XML attribute name to getdefault (
Optional[str]) – Default value to return if the attribute does not exist
- Return type:
Optional[str]
- set(name, value)¶
Set an XML attribute to the SVG elemenet
- Parameters:
name (
str) – The SVG/XML attribute name to setvalue (
str) – Value of the attribute
- Return type:
- subelement(element)¶
Add an XML/SVG sub element
- Parameters:
element (
str|Element) – The element to add, either as text or an ET.Element instance.- Return type:
- class ziaplot.attributes.Animatable¶
SVG attributes and subelements, with functions for adding SMIL annimation elements
- animate(attribute, to, frm, begin='', duration='', repeat='indefinite')¶
Animate an attribute. (Note parameters are in SVG coordinates, not drawing coordinates)
- Parameters:
attribute (
str) – name of the attribute to setto (
str) – Value to set the attributefrm (
str) – Initial value of the attributebegin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time from start to end of the pathrepeat (
str) – Number of times to repeat, or ‘indefinite’
- Return type:
- animate_in(begin='', duration='', repeat='')¶
Animate the path as if it is being drawn
- Parameters:
begin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time from start to end of the pathrepeat (
str) – Number of times to repeat, or ‘indefinite’
- Return type:
- animate_move(path, begin='', duration='', repeat='indefinite', rotate='auto')¶
Animate the object, moving it along path defined by the path component. Sets the <animateMotion> svg tag.
- Parameters:
path (
Component) – Another drawing component, containing a path (such as a Segment, Bezier, or PolyLine)begin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time from start to end of the pathrepeat (
str) – Number of times to repeat, or ‘indefinite’rotate (
str) – Whether to rotate the element in the direction of motion, may be ‘auto’, ‘auto-reverse’, or ‘0’
- Return type:
- animate_out(begin='', duration='', repeat='')¶
Animate the path as if it is being erased
- Parameters:
begin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time from start to end of the pathrepeat (
str) – Number of times to repeat, or ‘indefinite’
- Return type:
- animate_set(attribute, to, begin='', duration='')¶
Animate an attribute value of the element (using svg <set> tag)
- Parameters:
attribute (
str) – name of the attribute to setto (
str) – Value to set the attributebegin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time to leave the attribute set, or ‘indefinite’.
- Return type:
- animate_show(begin='', duration='')¶
Animate the visibile attribute
- Parameters:
begin (
str) – Time or other criteria at which to set the attribute. Should be a string with units, e.g. ‘2s’. (see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/begin)duration (
str) – Length of time from start to end of the path
- Return type:
Geometric Calculations¶
A few calculation functions are made available to the user.
- ziaplot.geometry.distance(p1, p2)¶
Distance between two points
- Return type:
float
- ziaplot.geometry.isclose(p1, p2)¶
Determine if the points are identical (x and y within math.isclose)
- Return type:
bool
- ziaplot.geometry.midpoint(p1, p2)¶
Midpoint between two points
- Return type:
Tuple[float,float]
- ziaplot.geometry.translate(point, delta)¶
Translate the point by delta
- Return type:
Tuple[float,float]
- ziaplot.geometry.reflect(point, line)¶
Reflect the point over the line
- Return type:
Tuple[float,float]
- ziaplot.geometry.rotate(point, theta)¶
Rotate the point theta radians about the origin
- Return type:
Tuple[float,float]
- ziaplot.geometry.image(point, line)¶
Create a new point imaged onto the line (point on line at shortest distance to point)
- Return type:
Tuple[float,float]
- ziaplot.geometry.angle_mean(theta1, theta2)¶
Circular mean over 0 to 2pi (theta in radians)
- Return type:
float
- ziaplot.geometry.angle_diff(theta1, theta2)¶
Get angular difference between theta2 and theta1 (radians)
- ziaplot.geometry.angle_isbetween(angle, theta1, theta2)¶
Is angle between theta1 and theta2 counterclockwise?
- Return type:
bool
- ziaplot.geometry.line.slope(line)¶
Get slope of the line
- Return type:
float
- ziaplot.geometry.line.intercept(line)¶
Get y-intercept of the line
- Return type:
float
- ziaplot.geometry.line.xintercept(line)¶
Get x-intercept of the line
- Return type:
float
- ziaplot.geometry.line.yvalue(line, x)¶
Get y value of the line at x
- Return type:
float
- ziaplot.geometry.line.xvalue(line, y)¶
Get x value of the line at y
- Return type:
float
- ziaplot.geometry.line.normal_distance(line, point)¶
Normal distance from point to line
- Return type:
float
- ziaplot.geometry.line.bisect(line1, line2)¶
Find the two lines bisecting the given two lines
- Return type:
tuple[Tuple[float,float,float],Tuple[float,float,float]]
- ziaplot.geometry.line.bisect_points(p1, p2)¶
Find the line bisecting the two points
- Return type:
Tuple[float,float,float]
- ziaplot.geometry.circle.point(circle, theta)¶
Coordinates of point on circle at angle theta (rad)
- Return type:
Tuple[float,float]
- ziaplot.geometry.circle.tangent_angle(theta)¶
Angle of tangent to circle at given theta around circle
- Return type:
float
- ziaplot.geometry.circle.tangent_at(circle, theta)¶
Find tanget to circle at given theta
- Return type:
Tuple[float,float,float]
- ziaplot.geometry.circle.tangent_points(circle, p)¶
Find the two points on the circle that form a tangent line through the given point
- Return type:
tuple[Tuple[float,float],Tuple[float,float]]
- ziaplot.geometry.circle.tangent(circle, p)¶
Find tangent points and slope of the two tangents to the circle through the point p
- Return type:
tuple[tuple[Tuple[float,float],float],tuple[Tuple[float,float],float]]
- ziaplot.geometry.ellipse.point(ellipse, theta)¶
Get point on ellipse at angle theta
- Return type:
Tuple[float,float]
- ziaplot.geometry.ellipse.tangent_points(ellipse, p)¶
Find the two points on the Ellipse that form a tangent line through the given point
- Return type:
tuple[Tuple[float,float],Tuple[float,float]]
- ziaplot.geometry.ellipse.tangent_angle(ellipse, theta)¶
Angle (radians) tangent to the Ellipse at theta (radians)
- Return type:
float
- ziaplot.geometry.function.local_max(f, x1, x2)¶
Find local maximum of function f between x1 and x2
- Return type:
Tuple[float,float]
- ziaplot.geometry.function.local_min(f, x1, x2)¶
Find local minimum of function f between x1 and x2
- Return type:
Tuple[float,float]
- ziaplot.geometry.function.tangent(f, x)¶
Find tangent to function at x
- Return type:
Tuple[float,float,float]
- ziaplot.geometry.function.normal(f, x)¶
Find normal to function at x
- Return type:
Tuple[float,float,float]
- ziaplot.geometry.bezier.xy(b, t)¶
Point on a Bezier curve at parameter t
- Return type:
Tuple[float,float]
- ziaplot.geometry.bezier.tangent_slope(b, t)¶
- Return type:
float
- ziaplot.geometry.bezier.tangent_angle(b, t)¶
- Return type:
float
- ziaplot.geometry.bezier.length(b, n=50)¶
Compute approximate length of Bezier curve (Quadtratic or Cubic)
- Parameters:
n (
int) – Number of points used for piecewise approximation of curve- Return type:
float
- ziaplot.geometry.bezier.equal_spaced_points(b, nsegments=2, n=100)¶
Find (x, y) points spaced equally along a Bezier curve
- Parameters:
bezier – The curve to split
nsegments (
int) – Number of segments to split curve inton (
int) – Number of points used to approximate curve
- Return type:
list[Tuple[float,float]]
- ziaplot.geometry.intersect.lines(line1, line2)¶
Find point of intersection of two lines
- Return type:
Tuple[float,float]
- ziaplot.geometry.intersect.line_angle(line1, line2)¶
Find angle (rad) of intersection between the two lines
- Return type:
float
- ziaplot.geometry.intersect.line_circle(line, circle)¶
Find intersections between line and circle
- Return type:
tuple[Tuple[float,float],Tuple[float,float]]
- ziaplot.geometry.intersect.circles(circle1, circle2)¶
Get points of intersection between two circles
- Return type:
tuple[Tuple[float,float],Tuple[float,float]]
- ziaplot.geometry.intersect.line_arc(line, arc)¶
Find intersection of line and arc. Same as circle, but ensures point falls on the arc
- ziaplot.geometry.intersect.functions(f1, f2, x1, x2)¶
Find intersection between two Functions in the interval x1 to x2. Raises ValueError if the curves do not intersect.
- Return type:
Tuple[float,float]
- ziaplot.util.linspace(start, stop, num=50)¶
Generate list of evenly spaced points
- Return type:
list[float]