Plotting¶
tsecon.plot(*series, backend="auto" | "matplotlib" | "plotly", ...) plus
TSeries.plot(...) / MVTSeries.plot(...) method delegates. Both backends are
optional install extras; the dispatcher lazy-imports via importlib.util.find_spec
and raises BackendNotAvailableError with an install hint when neither is present.
tsecon.plotting ¶
TimeSeriesEcon plotting adapter.
The public entry point is :func:plot, which routes a sequence of
:class:~tsecon.tseries.TSeries or :class:~tsecon.mvtseries.MVTSeries
arguments to one of the bundled backends (matplotlib or plotly)
and returns that backend's native figure object. Methods
:meth:~tsecon.tseries.TSeries.plot and
:meth:~tsecon.mvtseries.MVTSeries.plot delegate here.
The backends are optional dependencies (extras matplotlib and
plotly in pyproject.toml); neither is imported at package import
time. backend="auto" resolves to the first installed backend in the
preference order matplotlib -> plotly; passing backend="matplotlib"
or backend="plotly" raises :class:ImportError with an install hint
if that backend is missing.
BackendName
module-attribute
¶
Named backends supported by :func:plot.
BackendNotAvailableError ¶
available_backends ¶
Return the names of installed plotting backends in preference order.
resolve_backend ¶
Resolve backend="auto" to the first available backend.
Raises :class:BackendNotAvailableError if the requested backend (or
auto with no backends installed) is not available, with a
pip-extras install hint.
Source code in src/tsecon/plotting/__init__.py
plot ¶
plot(
*series: TSeries | MVTSeries,
backend: BackendName = "auto",
trange: MITRange | None = None,
mit_loc: MitLoc = "left",
label: str | Sequence[str] | None = None,
vars: Sequence[str | tuple[str, str]] | None = None,
title: str | None = None,
xlabel: str | None = None,
ylabel: str | None = None,
legend: bool = True,
figsize: tuple[float, float] | None = None,
**kwargs: Any,
) -> Any
Plot one or more TSeries (single-axes) or MVTSeries (panel-grid) datasets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*series
|
TSeries or MVTSeries
|
One or more series of a single kind — mixing TSeries and MVTSeries in
one call raises :class: |
()
|
backend
|
('auto', 'matplotlib', 'plotly')
|
|
"auto"
|
trange
|
MITRange
|
Limit the rendered window to this range. All series must share a frequency. |
None
|
mit_loc
|
('left', 'middle', 'right')
|
Where in each period interval the value's x-coordinate sits. For
Daily / BDaily / Weekly the position is fixed at the period date
and |
"left"
|
label
|
str or sequence of str
|
One label per series (TSeries) or per dataset (MVTSeries). |
None
|
vars
|
sequence of str or (str, str)
|
For MVTSeries: select / order the variables shown. Each item is
either a column name or a |
None
|
title
|
str
|
Standard chart annotations. For panel plots, |
None
|
xlabel
|
str
|
Standard chart annotations. For panel plots, |
None
|
ylabel
|
str
|
Standard chart annotations. For panel plots, |
None
|
legend
|
bool
|
Whether to draw a legend. |
True
|
figsize
|
(float, float)
|
Matplotlib figure size (inches). The plotly backend interprets this as pixels at 100 DPI. |
None
|
Returns:
| Type | Description |
|---|---|
Figure or Figure
|
The backend's native figure object. |
Source code in src/tsecon/plotting/__init__.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |