Skip to main content

Fluent Bokeh charting for Polars and Pandas DataFrames

Project description

Xpectral Chart

Spectral decomposition

Fluent Bokeh charting that extends Polars and Pandas DataFrames via the accessor pattern: df.bokeh.line(...), df.bokeh.scatter(...), and more.

Part of the Xpectral project, alongside xpectral-quant (financial metrics and market data). Both install into the shared xpectral namespace and can be used together.

Usage

import xpectral.charts  # registers the df.bokeh accessor
from xpectral.charts import PandasDataFrame
from xpectral.charts import PolarsDataFrame

df: PolarsDataFrame = pl.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]})
fig = df.bokeh(title="Example", width=600, height=400)
fig.line(x="x", y="y")

pd_df: PandasDataFrame = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]})
pd_fig = pd_df.bokeh(title="Example", width=600, height=400)
pd_fig.line(x="x", y="y")

Importing xpectral.charts is what registers the accessor on Polars and Pandas DataFrames. Annotate sample DataFrames with PolarsDataFrame or PandasDataFrame when you want the editor (pyright) to resolve the df.bokeh(...) parameters and chained accessor methods — annotation is necessary for type hinting, as accessors are not discovered dynamically.

Custom chart methods

Use BokehAccessor.register to add your own methods to the accessor. The decorated function receives self — the accessor instance — giving access to self._df, self.source, self.plot, and all built-in glyph methods.

from xpectral.charts import BokehAccessor

@BokehAccessor.register
def price_band(self, mid, upper, lower, **kwargs):
    self.line(y=mid, **kwargs)
    self.varea(y1=lower, y2=upper, fill_alpha=0.2, **kwargs)

fig = df.bokeh(title="Bands", width=800, height=400)
fig.price_band(mid="close", upper="upper", lower="lower")

The method is available on both Polars and Pandas accessors immediately after registration.

See xpectral/charts/README.md for the module-level documentation (glyph methods, stacks, auto-color, themes, datetime axes).

Install

pip install xpectral-chart
uv add xpectral-chart

For development:

uv sync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpectral_chart-1.0.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xpectral_chart-1.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file xpectral_chart-1.0.0.tar.gz.

File metadata

  • Download URL: xpectral_chart-1.0.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xpectral_chart-1.0.0.tar.gz
Algorithm Hash digest
SHA256 27d3cdb855352ebc65b69e75d333792b90662f99a5a3f44056317cf7961d2238
MD5 224c9e2dc71010ec3025a2ad19e5e50e
BLAKE2b-256 bc8e9b1349e9b5d083b76ea1b3904d6e40a5fa519162fb67cf4f1e63d2ec7ac3

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpectral_chart-1.0.0.tar.gz:

Publisher: publish.yml on bayquant/xpectral-chart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xpectral_chart-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: xpectral_chart-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xpectral_chart-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87b46dc269a3c3c1377768767207ea8cdfc7932d4582e477103fc4a2509c171a
MD5 39759d8871cf2f62ba778541083d213a
BLAKE2b-256 9f60beef8e458a5ab37a99e8aeb2a7b17af2e50c81663753862a114345ff8b96

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpectral_chart-1.0.0-py3-none-any.whl:

Publisher: publish.yml on bayquant/xpectral-chart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page