Skip to content

Reporting, reproducibility & translation

The classes and functions of the row "Reporting, reproducibility & translation" of Analytical tools, with what calls return (the results and their methods: forecasts, impulse responses, tests). Import them from pymetrix (from pymetrix import ...) unless a heading names another module. Parameters and return types are in each signature; the text says what each does.

Help topics: Reports.

How do I: Translate an EViews program, Make a report.

From a plugin: pymetrix-eviews has more for this area.

From a plugin: pymetrix-labbook has more for this area.

From a plugin: pymetrix-r has more for this area.

Classes

pymetrix.extension.ReportTemplate dataclass

ReportTemplate(name: str, description: str, sections: tuple[str, ...] | str, provenance: bool = True, version: int = 1)

A named report layout: which views of each result to include, in order, and whether to add provenance.

pymetrix.figures.Band dataclass

Band(lower: Series, upper: Series, label: str = '', color: str | None = None, alpha: float = 0.18, axis: str = 'left', step: bool = False)

A shaded interval, e.g. confidence bands.

pymetrix.figures.Bars dataclass

Bars(y: Series, label: str = '', color: str | None = None, stacked: bool = False, horizontal: bool = False, axis: str = 'left', base: Series | None = None)

Bars of a series. Unstacked bars in the same panel stand side by side; horizontal draws them across; bars with a base float, each from its base, as the steps of a waterfall chart.

pymetrix.figures.Contour dataclass

Contour(values: DataFrame, levels: int | tuple[float, ...] = 10, filled: bool = True, clabel: bool = False, cmap: str = 'viridis', color: str | None = None, colorbar: bool = True, label: str = '')

Contours of a table over a grid (matplotlib's contourf, filled, or contour, lines): the table's columns along x, its rows along y (numbers, dates or names), each cell's value the height. levels: how many (matplotlib chooses round values) or the levels themselves; clabel writes each line's level on it (filled contours get thin lines at their levels to carry them, as matplotlib advises); color draws the lines in one colour instead of the colour map (lines over a filled contour); colorbar with label names the levels.

pymetrix.figures.Ecdf dataclass

Ecdf(values: Series, label: str = '', color: str | None = None, complementary: bool = False)

The empirical cumulative distribution of a series (matplotlib's ecdf): at each value, the share of observations at or below it, as a step. complementary draws the share above it instead. Several in one panel compare distributions without choosing bins.

pymetrix.figures.Estimates dataclass

Estimates(estimate: Series, lower: Series, upper: Series, label: str = '', color: str | None = None, marker: str = 'o')

Point estimates with intervals, as matplotlib's errorbar draws them: a marker at each estimate and a line across its interval. Named estimates (coefficients, models) are listed down the side with a dashed line at zero; dated ones (a coefficient over time) run along the dates. Several in one panel stand side by side, as bars do.

pymetrix.figures.Heatmap dataclass

Heatmap(values: DataFrame, label: str = '', cmap: str = '', center: float | None = None, vmin: float | None = None, vmax: float | None = None, annotate: bool = True, fmt: str = '{:.2f}', scale: Literal['table', 'column', 'auto'] = 'table', hatch: str = '', thresholds: tuple[float, ...] = (), separators: tuple[int, ...] = (), date_format: str = '', bands: DataFrame | None = None)

A table of values as coloured cells (matplotlib's imshow) with a colour bar: correlations, responses by shock and horizon, p-values. Values of both signs (or with center given) get a diverging scale, symmetric about the centre (zero by default); others a sequential one. annotate writes each value in its cell, as fmt formats it, when there are at most 400 cells, in dark or white type, whichever reads better on the cell.

scale "table" colours every cell on one scale; "column" colours each column on its own (its smallest value at one end of the colour map, its largest at the other; center, vmin and vmax do not apply), for a table whose columns are in different units, such as a posterior summary's means beside its effective draws: the cells still show their own values, and a note under the table takes the colour bar's place. "auto" picks "column" when one column's typical size (the median of its absolute values) is more than ten times the largest absolute value in another, and "table" otherwise, and always for a square matrix with the same labels on its rows and columns (correlations, covariances), for columns that are horizons, lags or dates (responses by horizon), for columns that all take values above and below zero (responses by shock, residuals), and for shares (no value below zero, and every row, or every column, adding up to the same whole multiple of 1 or of 100: variance decompositions).

For surveillance charts (indicators down the side, dates across): hatch draws a hatch pattern ("///") on missing cells, so a gap reads as missing rather than as the colour of zero; thresholds colours by bands of cut-offs ((10, 25, 75, 90) on percentile ranks: five colours from the colour map) instead of a continuous scale; separators draws a line under the given rows (counted from the top: (3, 7) after the third and the seventh), between groups; date_format writes columns that are dates with that strftime format ("%Y", "%b %y", or "%YQ%q" for quarters) and labels at most about twelve of them; bands is a table of regimes drawn as strips of colour above the cells, one row per band (its name the row label), one column per column of values in the same order, each value a category (cluster 1, 2, ...; 0 and 1 for a recession dummy; missing left blank).

pymetrix.figures.Hexbin dataclass

Hexbin(x: Series, y: Series, gridsize: int = 30, cmap: str = 'Blues', label: str = 'observations')

Hexagonal bins (matplotlib's hexbin): the plane of x against y cut into hexagons, gridsize across, each coloured by how many observations fall in it, with a colour bar; empty hexagons are left out. For large scatters, as Hist2d, with cells that tile the plane more evenly.

pymetrix.figures.Hist2d dataclass

Hist2d(x: Series, y: Series, bins: int = 30, cmap: str = 'Blues', label: str = 'observations')

A two-dimensional histogram (matplotlib's hist2d): the plane of x against y cut into bins by bins cells, each coloured by how many observations fall in it, with a colour bar. A scatter plot for many observations, where points would hide each other.

pymetrix.figures.Histogram dataclass

Histogram(values: Series, bins: int = 30, normal: bool = True, label: str = '')

pymetrix.figures.Line dataclass

Line(y: Series, label: str = '', color: str | None = None, style: str = '-', width: float = 1.6, step: bool = False, axis: str = 'left')

pymetrix.figures.Line3d dataclass

Line3d(x: Series, y: Series, z: Series, label: str = '', color: str | None = None, width: float = 1.6)

A line through the points (x, y, z) on a 3-D panel (Axes3D.plot). A series of periods on any axis is drawn as dates. Styled as a line (fig.line(label, ...)).

pymetrix.figures.Panel dataclass

Panel(layers: tuple[Any, ...], title: str = '', ylabel: str = '', xlabel: str = '', legend: bool = True, ylabel_right: str = '', zlabel: str = '', projection: str = '', legend_loc: str = '')

One panel of a figure (a matplotlib Axes): its layers, title and axis labels. A panel of surfaces, 3-D lines and 3-D points is a 3-D panel (projection="3d"), with a zlabel; it holds no flat layers.

drawn

drawn() -> tuple[Any, ...]

The layers as drawn: a fan as its bands, central line and start line.

pymetrix.figures.QQ dataclass

QQ(values: Series, label: str = '')

A normal Q-Q plot: the values, standardised and sorted, against the normal distribution's quantiles at the same probabilities, (i - 0.5) / n, with the 45-degree line they lie along if they are normal. Points above it on the right and below it on the left mean fat tails; a bow means skew.

pymetrix.figures.Rule dataclass

Rule(y: float = 0.0, style: str = '-', color: str = '#888888', vertical: bool = False)

A horizontal reference line (zero, or a significance band); vertical for one across the x-axis instead (the zero of horizontal bars, or a date, given as a period, on a dated axis).

pymetrix.figures.Scatter dataclass

Scatter(x: Series, y: Series, label: str = '', fit: bool = False)

pymetrix.figures.Scatter3d dataclass

Scatter3d(x: Series, y: Series, z: Series, label: str = '', color: str | None = None)

Points (x, y, z) on a 3-D panel (Axes3D.scatter); a series of periods on any axis is drawn as dates.

pymetrix.figures.Surface dataclass

Surface(values: DataFrame, label: str = '', cmap: str = 'viridis', wireframe: bool = False, color: str | None = None, alpha: float = 1.0)

A surface over a grid, on a 3-D panel (matplotlib's plot_surface, or plot_wireframe with wireframe): the table's columns along x (maturities, horizons, strikes), its rows along y (dates, expiries), each cell's value the height z. A surface is coloured by height, with a colour bar named label; a wireframe is lines in color. Every cell is drawn (no thinning). Turn it with Figure.view_init.

pymetrix.figures.Violin dataclass

Violin(series: tuple[Series, ...], labels: tuple[str, ...] = (), medians: bool = True)

Violin plots (matplotlib's violinplot): for each series, its kernel density (Gaussian, Scott's bandwidth) drawn mirrored about an upright line from its lowest to its highest value, with the median marked. A box plot that shows the distribution's shape: two humps, a long tail.

Report dataclass

Report(title: str, author: str = '', date: str = (lambda: isoformat())(), provenance: bool = True, theme: str | None = None, span: tuple[Any, Any] | None = None, template: str = '', figure_size: Any = (6.0, None), blocks: list[_Block] = list(), _sources: list[tuple[str, Any]] = list())

A document of headings, text, tables and figures, saved as .xlsx, .docx, .html or .md.

from_template classmethod

from_template(template: str, results: Any, title: str = '', author: str = '', theme: str | None = None, span: tuple[Any, Any] | None = None, date: str | None = None) -> Report

A report laid out by a named template (report_templates()). results maps headings to results (or is a list of results); each gets a heading and the template's views that it has.

caution

caution(text: str) -> Report

A warning at the top of the report (before any results), e.g. that a result in it is out of date.

text

text(text: str) -> Report

A paragraph; blank lines separate paragraphs.

add

add(obj: Any, caption: str = '', sections: Sequence[str] | str | None = None) -> Report

Add a table, a figure, or a result. A result adds its summary and its graph; sections picks others by the titles of its window's tabs, in that order (e.g. ["Summary", "Diagnostics"]), or "all".

Functions

coefficient_figure

coefficient_figure(results: Any, terms: Sequence[str] | None = None, alpha: float = 0.05, title: str = '') -> Figure

A coefficient plot: each estimate with its 1 - alpha interval, from one result or several (a mapping of names to results, or a sequence), side by side for each coefficient. Any result whose params give interval works (equations, and draws for Bayesian ones). terms picks and orders the coefficients.

figure_of

figure_of(obj: Any, tab: str = 'Graph') -> Any

The figure on a result's tab (its Graph tab by default), to change with with_options, e.g. figure_of(fit).with_options(title="Consumption", shade="2008Q3:2009Q2"). A figure is returned as it is.

heatmap_figure

heatmap_figure(values: Any, title: str = '', label: str = '', view: str | None = None, scale: Literal['table', 'column', 'auto'] = 'table', diagnostics: bool = True, **options: Any) -> Figure

A table as a heatmap (Heatmap): a DataFrame, a Table (its numeric columns), or a result's table named by view (heatmap_figure(granger, view="Results")). label names the colour bar; scale "table" (one scale), "column" (each column its own) or "auto" (by the columns' sizes, as Heatmap says); diagnostics=False leaves out a posterior table's sampling diagnostics (its R-hat, effective draws, ESS and MCSE columns), which describe the sampler rather than the posterior; cmap, center, vmin, vmax, annotate and fmt as the layer takes them.

house_style

house_style() -> tuple[StyleCall, ...]

The house style's calls (empty: none).

load_result

load_result(path: str | Path) -> SavedResult

Read a result saved by save_result.

pymetrix.extension.figure_views

_figure(make: Any) -> list[Section]

A "Graph" tab, if the object can be drawn (and matplotlib is installed).

pymetrix.extension.frame_table

_frame_table(frame: Any, title: str = '', notes: Any = ()) -> Table

pymetrix.extension.register_view

register_view(cls: type, fn: Any = None, *, plugin: Any = None) -> Any

Register fn(obj) -> [(title, Table), ...]: the tabs of an object window for result type cls.

Usable as a decorator: @register_view(MyResult). Plugins with new result types call this from a function named by a pymetrix.views entry point.

pymetrix.extension.view_sections

view_sections(obj: Any) -> list[Section]

sections after loading plugins' views.

pymetrix.extension.views_frame

_views_to_frame(self: Any, view: str | None = None) -> Any

One of the object's views as a DataFrame: the first table by default, or a view by name (the tabs of its window; case does not matter). views.titles(obj) lists them.

pymetrix.figures.contributions_figure

contributions_figure(parts: Mapping[str, Series] | DataFrame, total: Series | None = None, title: str = '', total_label: str = 'total', ylabel: str = '') -> Figure

A contributions chart: what each part added to a total, period by period, as stacked bars with the total as a line (contribution_layers). For growth decompositions, shock decompositions and the like.

pymetrix.figures.vintages_figure

vintages_figure(vintages: Mapping[str, Series] | DataFrame, title: str = '', ylabel: str = '') -> Figure

One line per release of a series, oldest first: the older ones lighter and thinner, the latest darkest, to show how the data were revised.

report_templates

report_templates() -> list[str]

The names of the report templates, the built-in ones and plugins'.

save_result

save_result(obj: Any, path: str | Path, name: str = '', call: Any = None) -> Path

Write obj (an estimate, test, forecast, solution... anything with a window) to path.

The suffix .pymxr is added when missing. name is the result's name (default: the file's).

The provenance keeps the call that made the result (provenance["call"]: the function's ID, its arguments as recorded, with the span and row condition as given, and the datasets and other objects it used, by name), so Call(**provenance["call"]).invoke({"data": data}) makes it again. A result a session step made has its call found (pymetrix.calls.call_of); call gives one (a Call) for a result made otherwise.

set_house_style

set_house_style(style: Any = None, notes: bool = False) -> tuple[StyleCall, ...]

Make a figure's recorded style the house style: every figure drawn from now on starts from it, call by call where the call applies (as with_style_of: its series, panels and right-hand axes), and its own calls come after, so they win. style is a figure or its style calls; None clears the house style. Notes, text, lines and bands are left out unless notes. A figure drawn with house=False ignores it. Returns the previous house style's calls, as set_theme returns the previous theme.

surface_figure

surface_figure(values: Any, kind: Literal['surface', 'wireframe', 'contourf', 'contour'] = 'surface', title: str = '', label: str = '', xlabel: str = '', ylabel: str = '', **options: Any) -> Figure

A table over a grid, its columns along x and its rows along y (numbers, dates or names), each value a height: kind surface or wireframe (3-D, Surface), contourf (filled contours) or contour (lines; Contour). label names the heights (the colour bar, and a surface's z axis); xlabel and ylabel the axes (the table's column and row names by default). Other keywords as the layer takes them: cmap, alpha, color for surfaces; levels, clabel, color, colorbar for contours. A yield curve over time is a table of dates by maturities; responses over time, of dates by horizons.

Results

Figure dataclass

Figure(panels: tuple[Panel, ...], title: str = '', columns: int = 1, width: float = 7.5, height: float | None = None, subtitle: str = '', footnote: str = '', theme: str | Theme | None = None, span: tuple[Any, Any] | None = None, shade: tuple[tuple[str, str, str], ...] = (), events: tuple[tuple[str, str], ...] = (), reference: tuple[tuple[float, str], ...] = (), log: bool = False, ylim: tuple[float | None, float | None] | None = None, sharey: bool = False, bar_labels: bool = False, line_labels: bool = False, style: tuple[StyleCall, ...] = (), house: bool = True, ybreak: tuple[float, float] | None = None, xbreak: tuple[Any, Any] | None = None)

Panels of layers, laid out columns across; width in inches. subtitle, footnote, theme and span (the dates drawn) are options: see with_options.

with_options

with_options(**options: Any) -> Figure

A copy drawn differently. The data are unchanged.

title, subtitle, footnote, theme, span, columns, width, height; shade (periods to shade: "2008Q3:2009Q2=GFC, 2020Q1:2020Q2"); events (labelled dates: "2016Q2=Brexit vote"); reference (labelled values: "2=inflation target"); log (a log scale); ylim ((lowest, highest), either None); sharey (one scale for all panels); bar_labels (values on the bars); line_labels (each line named at its end instead of in the legend); house (False: without the house style); ybreak ((low, high), or "5:15": the values between left out, each panel whose values span them drawn in two parts, one above the other, with break marks: for a spike that squashes the rest); xbreak ((first, last) periods, or "1986Q1:2004Q4": those periods left out, each dated panel that spans them drawn in two parts side by side). One of the two per figure; a split value axis is for panels without a right-hand axis.

line

line(label: str, ax: int | str | None = None, **props: Any) -> Figure

Style the line of the series label, as Line2D.set takes it: color, linestyle, linewidth, marker, markersize, alpha, zorder and the rest (aliases such as lw and ls too). ax: the panel (a position or its title); by default, wherever the series is drawn.

bars

bars(label: str, ax: int | str | None = None, **props: Any) -> Figure

Style the bars of the series label, as Rectangle.set takes it: color, edgecolor, linewidth, hatch, alpha...

band

band(label: str, ax: int | str | None = None, **props: Any) -> Figure

Style the shaded band (area) of label, as a PolyCollection takes it: facecolor, alpha, hatch, edgecolor...

set

set(ax: int | str = 0, side: str = 'left', **props: Any) -> Figure

Set a panel's axes, as Axes.set takes it: xlim, ylim (dates as periods, e.g. ("2010Q1", "2020Q4")), xscale, yscale, xlabel, ylabel, title, aspect... ax: the panel (a position, its title, or "all"); side="right": its right-hand axis.

ticks

ticks(ax: int | str = 0, axis: str = 'both', format: str | None = None, **props: Any) -> Figure

Ticks, as Axes.tick_params takes them (labelsize, rotation, direction, length...), and format, a format string for the tick labels as StrMethodFormatter takes it: "{x:,.0f}", "{x:.0%}".

grid

grid(ax: int | str = 0, visible: bool = True, **props: Any) -> Figure

Grid lines, as Axes.grid takes them: visible, which, axis, color, linestyle, alpha...

spines

spines(ax: int | str = 0, which: str = 'all', **props: Any) -> Figure

The frame's sides (left, right, top, bottom or all), as Spine.set takes them: visible, color, linewidth...

legend

legend(ax: int | str = 0, **props: Any) -> Figure

The legend, as Axes.legend takes it: loc, ncols, frameon, fontsize, title, bbox_to_anchor...; visible=False removes it.

annotate

annotate(text: str, xy: Any, xytext: Any = None, ax: int | str = 0, **props: Any) -> Figure

A note at xy, as Axes.annotate takes it: fig.annotate("Lehman", xy=("2008Q3", 3.2), xytext=("2008Q3", 6), arrowprops=dict(arrowstyle="->")). Dates are the data's periods; textcoords="offset points" puts the text that many points from xy (xytext=(15, 20)); fontsize, color, ha... too.

text

text(x: Any, y: Any, s: str, ax: int | str = 0, **props: Any) -> Figure

Text at (x, y), as Axes.text takes it (x a period on a dated axis); fontsize, color, ha, va, rotation, bbox...

axhline

axhline(y: float = 0, ax: int | str = 0, **props: Any) -> Figure

A horizontal line across the panel at value y, as Axes.axhline takes it (color, linestyle...).

axvline

axvline(x: Any, ax: int | str = 0, **props: Any) -> Figure

A vertical line at x (a period on a dated axis), as Axes.axvline takes it.

axhspan

axhspan(ymin: float, ymax: float, ax: int | str = 0, **props: Any) -> Figure

A shaded band between two values, as Axes.axhspan takes it (color, alpha...).

axvspan

axvspan(xmin: Any, xmax: Any, ax: int | str = 0, **props: Any) -> Figure

A shaded band between two dates (periods; the whole of the last), as Axes.axvspan takes it.

change

change(series: str, start: Any, end: Any, show: str = 'both', units: str = 'auto', annualise: bool = False, ax: int | str | None = None, **props: Any) -> Figure

The change in series between two points, drawn as a double-headed arrow (style="bracket": a bracket) from one to the other, labelled at its middle: fig.change("unemployment", "2019Q4", "2020Q2").

start and end are periods on a dated axis (numbers otherwise); the values are read from the series as drawn each time the figure is, so the label follows the data. show: "change", "percent" (percent change) or "both". units for the change: "auto" (percentage points, pp, when the panel's axis is a rate or a percentage, else none), "pp", "%" or "none". annualise=True adds the rate a year (compound for the percent change). color, fontsize, linewidth and style style it. ax: the panel; by default wherever the series is drawn.

view_init

view_init(elev: float | None = None, azim: float | None = None, roll: float | None = None, ax: int | str = 0) -> Figure

Turn a 3-D panel, as Axes3D.view_init does: elev, the angle above the x-y plane, and azim, the angle around the vertical axis, in degrees (matplotlib's default view is elev=30, azim=-60); roll about the line of sight. ax: the panel (a position, its title, or "all", every 3-D panel).

call

call(method: str, *args: Any, ax: int | str = 0, side: str = 'left', **kwargs: Any) -> Figure

Any other Axes method that styles or annotates a panel, recorded as data: fig.call("set_aspect", "auto"), fig.call("ticklabel_format", axis="y", style="sci", scilimits=(0, 0)), fig.call("minorticks_on"). The arguments are matplotlib's own, as plain data (positions in matplotlib's numbers). pymetrix.figure_properties. axes_methods() lists the methods: those that plot more data, clear things or need Python objects are not among them.

style_steps

style_steps() -> list[str]

The recorded style calls, in the order applied, each as the call that records it: line('gc', color='C3'), set(ax=0, ylabel='%'), annotate(text='Lehman', xy=('2008Q3', 3.2), ax=0). Their positions are the step numbers without_style, reorder_style and restyle take.

without_style

without_style(*steps: int) -> Figure

A copy without the style calls at these positions (as style_steps numbers them; -1 is the last).

reorder_style

reorder_style(order: Sequence[int]) -> Figure

A copy with the style calls in this order, by position; those not listed are removed. Calls apply in order, so where two set the same thing, the later one shows.

restyle

restyle(step: int, replace_all: bool = False, **props: Any) -> Figure

A copy with style call step's keyword arguments changed: fig.restyle(0, color="C2"). None removes one; replace_all=True replaces them all with props. The call's series, panel and place in the order are kept, and matplotlib checks the new values as when it was first set.

with_style_of

with_style_of(other: Figure | Sequence[StyleCall], notes: bool = False) -> Figure

A copy styled as other is: its recorded style calls added after this figure's own, where they apply.

  • A series' call (line, bars, band) is copied if this figure draws that series that way.
  • A panel's call is copied if this figure has that panel (by position or title) and, for a right-hand axis, if the panel has one; layout always is.
  • Notes, text, lines and bands (annotate, text, axhline...) mark the other chart's data, so they are copied only with notes=True.

style_skipped(other) lists the calls left out.

style_skipped

style_skipped(other: Figure | Sequence[StyleCall], notes: bool = False) -> list[str]

The style calls of other that with_style_of would leave out here.

to_matplotlib

to_matplotlib() -> Any

The drawn matplotlib.figure.Figure, to finish by hand. What is done to it is not recorded: record changes with the style calls (line, set, annotate, call...) instead.

matplotlib_code

matplotlib_code() -> str

A standalone script (NumPy, pandas and matplotlib only) that draws this figure from its numbers, every option and style call written as the matplotlib call it is: to check the chart, or reuse it, without pymetrix.

layout

layout(**props: Any) -> Figure

The whole figure: figsize (inches), or figwidth or figheight alone; dpi, facecolor, suptitle, supxlabel, supylabel.

drawn_height

drawn_height() -> float

The height drawn, in inches: as given, or by the rows of panels (taller where a panel is 3-D, to show its depth).

draw

draw(font: str | None = None, surface: Any = None) -> Any

A matplotlib figure (without pyplot, so it works in the app, notebooks and scripts alike), in the house look (pymetrix.figure_style). font: a font family to draw the text in (the app passes its own); surface: what it is drawn on, figure_style.LIGHT (the default, as every saved file is) or a window's colours (figure_style.surface_from). Neither changes the figure's size in inches.

png

png(dpi: int = 110, size: Any = None) -> bytes

The figure as PNG bytes; size as save takes it (a preset, or width and height).

save

save(path: str, dpi: int = 150, size: Any = None, transparent: bool = False, editable_text: bool = False) -> Path

Write the figure; the format follows the extension (.png, .pdf, .svg, .eps, .jpg...). Returns the path.

size: a preset (SIZES: "column", "page", "slide", "half-a4"), or (width, height) as inches or as text with units (("120mm", "80mm"), ("4in", None)); a height of None keeps the figure's shape. Text stays at its size in points, so a narrower figure has relatively larger type, as print needs. transparent: no background. PDF and EPS embed their fonts as TrueType (what journals ask for); SVG draws text as outlines, or keeps it as text to edit with editable_text. The file records what made it: pymetrix's and matplotlib's versions, the title, the series and the recorded style calls (in PNG text, PDF Subject or SVG Description).

describe

describe(technical: bool = True) -> str

What the figure shows and how it was made, in words: its title, the series in each panel, the options and the recorded style calls, and the versions that drew it (the text a saved file records). technical=False keeps what a reader needs (the title, subtitle, panels and series, the footnote): the alt text reports give figures.

data

data() -> DataFrame

Every series drawn, side by side (to copy into a spreadsheet). Two series with the same name (two unnamed bands, say) both appear, the second as "name (2)".

pymetrix.figures.Fan dataclass

Fan(center: Series, lower: tuple[Series, ...], upper: tuple[Series, ...], coverages: tuple[float, ...] = (0.9, 0.6, 0.3), label: str = 'central', color: str | None = None, start: bool = True, axis: str = 'left')

A fan chart: a central path, bands around it at several coverages (the inner ones darker, as each band overlaps the wider ones), and a dashed line where the bands, the forecast, begin. Drawn as its parts: a band per coverage (labelled "90%", "60%"...), the central line (label) and the start line, so each can be styled.

Fan.from_frame(frame, "gdp") reads the bands from gdp_lo90/gdp_hi90 columns (any coverages present), or makes normal bands from a gdp_se column; Fan.normal(center, se) from a standard error.

normal classmethod

normal(center: Series, se: Series, coverages: Sequence[float] = (0.3, 0.6, 0.9), **options: Any) -> Fan

Normal bands: the centre plus and minus the normal quantile for each coverage, times se.

from_frame classmethod

from_frame(frame: DataFrame, name: str, coverages: Sequence[float] | None = None, **options: Any) -> Fan

The fan of column name: bands from {name}_lo{pct} and {name}_hi{pct} columns (those of coverages, or every one present), else normal bands from {name}_se (coverages 30%, 60% and 90% by default).

parts

parts() -> tuple[Any, ...]

What is drawn: the bands, widest first, the central line, and the start line.

SavedResult dataclass

SavedResult(kind: str, name: str, saved: str, package_version: str, views: tuple[tuple[str, Any], ...], text: str = '', provenance: Mapping[str, Any] = dict(), source: str = '', record: Mapping[str, Any] = dict(), build: Mapping[str, Any] = dict())

A result read from a .pymxr file: its views, summary and provenance as they were when saved.

kind is the original result's type ("FittedEquation"), views its tabs in order as (title, Table or Figure), text its summary, provenance how it was made (a dictionary), and source the file it was read from.

stats property

stats: dict[str, float]

The fit statistics, by name.

summary

summary() -> str

The result as text, as its summary() printed when it was saved.

coefficients

coefficients() -> DataFrame

The tidy coefficient table, as the result's coefficients() gave it when saved.

statistics

statistics() -> DataFrame

The tidy statistics, with their definitions, as when saved.

observations

observations() -> DataFrame

Actual, fitted and residual values on the data's periods, as when saved.

Table dataclass

Table(columns: Sequence[str], rows: Sequence[Sequence[Any]], index: Sequence[str] | None = None, title: str = '', notes: Sequence[str] = (), index_name: str = '', fills: Sequence[Sequence[str | None]] | None = None)

to_frame

to_frame() -> DataFrame

The table as a pandas DataFrame: one column per table column, indexed by the row labels if it has them.

to_csv

to_csv(sep: str = ',', header: bool = True) -> str

The numbers as text, at full precision: sep="\t" pastes into Excel. Missing values are blank.

to_markdown

to_markdown(digits: int = 4) -> str

A Markdown table (numbers right-aligned, at digits decimals), followed by the notes.

Other names

show

show(obj: Any, title: str | None = None) -> None

Show a result: its window in the desktop app, rich output in a notebook, text in a terminal.

show(fit), show(fits.coefficients()), show(data, "Revised data"). Nothing is shown while a project is being opened or results are being recomputed.