Plot Style

Plotting style is set using a ziaplot.styletypes.Style dataclass. Individual drawing axes take a style argument to specify the style of the axis and any data series it contains. To customize the style, typically start with the base Style and modify its attributes:

sty = zp.styles.Style()
sty.axis.bgcolor = '#d9f2fa'
sty.canvasw = 300
sty.canvash = 300
zp.XyPlot(style=sty)
_images/style_1_0.svg

To use the style for all plots, set the default style using ziaplot.styles.setdefault():

zp.styles.setdefault(sty)

Themes

A number of predefined styles (or themes) are built-in to Ziaplot. For example, to enable the “Taffy” theme for all plots, use:

zp.styles.setdefault(zp.styles.Taffy)

Default

zp.styles.setdefault(zp.styles.Default)
_images/style_3_0.svg

Taffy

zp.styles.setdefault(zp.styles.Taffy)
_images/style_4_0.svg

Pastel

zp.styles.setdefault(zp.styles.Pastel)
_images/style_5_0.svg

Bold

zp.styles.setdefault(zp.styles.Bold)
_images/style_6_0.svg

Dark

zp.styles.setdefault(zp.styles.Dark)
_images/style_7_0.svg

Dark Taffy

zp.styles.setdefault(zp.styles.DarkTaffy)
_images/style_8_0.svg

Dark Bold

zp.styles.setdefault(zp.styles.DarkBold)
_images/style_9_0.svg

Style Dataclass

The style dictionary is a set of nested dataclasses.

class ziaplot.styletypes.Style(series: ziaplot.styletypes.SeriesStyle = <factory>, axis: ziaplot.styletypes.AxisStyle = <factory>, tick: ziaplot.styletypes.TickStyle = <factory>, legend: ziaplot.styletypes.LegendStyle = <factory>, pie: ziaplot.styletypes.PieStyle = <factory>, polar: ziaplot.styletypes.PolarStyle = <factory>, smith: ziaplot.smithstyle.SmithStyle = <factory>, canvasw: float = 600, canvash: float = 400, bgcolor: str = 'none', colorcycle: ziaplot.colors.ColorCycle = <factory>)

Main Ziaplot Style

Parameters
  • series – Style for Series (lines, markers)

  • axis – Style for the axis

  • tick – Style for tick marks and labels

  • legend – Style for plot legend

  • pie – Style for pie charts

  • polar – Style for polar plots

  • smith – Style for Smith charts

  • canvasw – Width of full image

  • canvash – Height of full image

  • bgcolor – Color of background

  • colorcycle – Automatic colors for multiple lines

class ziaplot.styletypes.SeriesStyle(line: ziaplot.styletypes.LineStyle = <factory>, marker: ziaplot.styletypes.MarkerStyle = <factory>, text: ziaplot.styletypes.TextStyle = <factory>, yerror: ziaplot.styletypes.ErrorBarStyle = <factory>, xerror: ziaplot.styletypes.ErrorBarStyle = <factory>, fillcolor: Optional[str] = None, fillalpha: float = 0.3)

Style for generic data series

Parameters
  • line – Style of lines

  • marker – Style of markers

  • text – Style of text

  • yerror – Style of Y-error bars

  • xerror – Style of X-error bars

  • fillcolor – Style for filled LineFill series

  • fillalpha – Transparency factor (0-1) for LineFill series

class ziaplot.styletypes.LineStyle(color: str = 'undefined', stroke: Union[Literal[-, :, dotted, --, dashed, -., .-, dashdot], str] = '-', width: float = 2.0, strokecolor: str = 'black', strokewidth: float = 1)

Line Style

Parameters
  • color – Line color

  • stroke – Line style, name or SVG dash-array specification

  • strokecolor – Color for border of Bars

  • strokewidth – Width for border of Bars

class ziaplot.styletypes.MarkerStyle(shape: Optional[Literal[round, o, square, s, triangle, ^, triangled, v, larrow, <, arrow, >, +, x, -, |, undefined, None]] = None, color: str = 'undefined', strokecolor: str = 'black', strokewidth: float = 1, radius: float = 7.0, orient: bool = False)

Line Marker Style

Parameters
  • shape – Shape of marker

  • color – Marker color

  • strokecolor – Color for border

  • strokewidth – Width of border

  • radius – Pixel radius (or half-width) of marker

  • orient – Orient the marker along the line (ie for arrowheads)

class ziaplot.styletypes.TextStyle(font: str = 'sans-serif', size: float = 14, color: str = 'black')

Text Style

Parameters
  • font – Font family

  • size – Font point size

  • color – Font color

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

Style for Error Bars

Parameters
  • marker – Marker shape

  • stroke – Stroke/linestyle

  • length – Length of errorbar caps

  • width – Width of line between errorbar caps

class ziaplot.styletypes.AxisStyle(xname: ziaplot.styletypes.TextStyle = <factory>, yname: ziaplot.styletypes.TextStyle = <factory>, title: ziaplot.styletypes.TextStyle = <factory>, color: str = 'black', bgcolor: str = '#F6F6F6', xgrid: bool = True, ygrid: bool = True, framelinewidth: float = 2.0, fullbox: bool = False, gridcolor: str = 'lightgray', gridlinewidth: float = 1.0, gridstroke: Union[Literal[-, :, dotted, --, dashed, -., .-, dashdot], str] = 'dashed', xdatapad: float = 0.2, ydatapad: float = 0.2)

Style for X/Y Axis

Parameters
  • xname – Text style for x-axis label

  • yname – Text style for y-axis label

  • title – Text style for axis title

  • color – Color of axis lines and ticks

  • bgcolor – Fill color for axis background

  • xgrid – Show grid along x direction

  • ygrid – Show grid along y direction

  • framelinewidth – Width of axis frame/border

  • fullbox – Draw full rectangle around box

  • gridcolor – Color for grid lines

  • gridlinewidth – Width of grid lines

  • gridstroke – Line style or SVG dash-array specification for grid

  • xdatapad – Fraction of a tick to expand the data range

  • ydatapad – Fraction of a tick to expand the data range

class ziaplot.styletypes.TickStyle(length: float = 9.0, width: float = 2.0, text: ziaplot.styletypes.TextStyle = <factory>, textofst: float = 4, xstrformat: str = 'g', ystrformat: str = 'g', xminordivisions: int = 0, yminordivisions: int = 0, xlogdivisions: int = 10, ylogdivisions: int = 10, minorwidth: float = 1.0, minorlength: float = 5.0)

Style for tick marks

Parameters
  • length – Length of tick marks

  • width – Line width of tick marks

  • text – Text style for tick labels

  • textofst – Distance between tick and text

  • xstrformat – String formatter for x tick labels

  • ystrformat – String formatter for y tick labels

  • xminordivisions – Number of minor tick divisions between labeled ticks

  • yminordivisions – Number of minor tick divisions between labeled ticks

  • xlogdivisions – Number of minor divisions for logscale plots (2, 5, or 10)

  • ylogdivisions – Number of minor divisions for logscale plots (2, 5, or 10)

  • minorwidth – Line width of minor ticks

  • minorlength – Length of minor ticks

class ziaplot.styletypes.LegendStyle(text: ziaplot.styletypes.TextStyle = <factory>, border: str = 'black', fill: str = 'none')

Style for plot legend

Parameters
  • text – Text style

  • border – Color for legend box border

  • fill – Fill color for legend box

class ziaplot.styletypes.PolarStyle(rlabeltheta: float = 0, edgepad: float = 10, labelpad: float = 4, title: ziaplot.styletypes.TextStyle = <factory>)

Style for Polar plots

Parameters
  • rlabeltheta – Angle (degrees) for drawing r-value labels

  • edgepad – Distance between frame and canvas border

  • labelpad – Distance between frame and theta labels

  • title – Text style for title

class ziaplot.styletypes.PieStyle(strokecolor: str = 'black', strokewidth: float = 1, legend: ziaplot.styletypes.LegendStyle = <factory>, edgepad: float = 10, extrude: float = 20, title: ziaplot.styletypes.TextStyle = <factory>, label: ziaplot.styletypes.TextStyle = <factory>, labelpad: float = 4)

Style for pie charts

Parameters
  • strokecolor – Line color around each wedge

  • strokewisth – Line width around each wedge

  • legend – Legend style

  • edgepad – Distance from canvas edge to pie

  • extrude – Distance to extrude slices

  • title – Text style for title

  • label – Text style for wedge labels

  • labelpad – Distance from pie to wedge label

class ziaplot.styletypes.SmithStyle(grid: dict[str, SmithGrid] = <factory>, majorcolor: str = '#DDDDDD', majorwidth: float = 1.2, minorcolor: str = '#E8E8E8', minorwidth: float = 1.0)

Style for Smith Charts

grid

Dictionary of grid specifications. [coarse, medium, fine, extrafine]

Type

dict[str, SmithGrid]

majorcolor

Color for major grid lines

Type

str

majorwidth

Stroke width for major grid lines

Type

float

minorcolor

Color for minor grid lines

Type

str

minorwidth

Stroke width for minor grid lines

Type

float

class ziaplot.colors.ColorCycle(*colors: str)

Color cycle for changing colors of plot lines

Parameters

cycle – List of string colors, either SVG-compatible names or ‘#FFFFFF’ hex values

steps(n: int)None

Set number of steps in cycle