Skip to main content

icon

behaviz

A modular, multi-backend plotting library that gets you from raw data to a clean, clear and reproducible figures - fast.

OS Python License: GPL v3 Tests Docs

Why behaviz?

Scientific plotting libraries are powerful but can be verbose: you spend more time wrangling keyword arguments, call signatures, and styling than looking at your data. behaviz is built for researchers who want publication-quality plots without becoming matplotlib experts.

It aims to solve two problems:

  1. Consistent, reproducible plots for similar data: describe a plot once with a spec, reuse it everywhere.
  2. High-level calls with low-level control: simple functions like plot_line and plot_scatter that still let you reach any underlying plot property through keyword overrides.

The same code can render through matplotlib, seaborn, or bokeh, and you can switch backends with a single line.

Highlights

  • One simple call per plot: plot_line, plot_scatter, plot_bar, plot_step, plot_errorbar, plot_violin, plot_image,plot_fill_between, plot_pie, plot_hexbin
  • Three interchangeable backends: set_renderer("matplotlib" | "seaborn" | "bokeh")
  • Painless colorbars: plot_image(data, colorbar="label") — auto-sized, no mappable juggling
  • Plot from anything: NumPy arrays, pandas / polars DataFrames, or plain dicts
  • Opt-in hover-tooltips: (hover_annotate=True)
  • Cross-backend styling: canonical keywords (color, linewidth, alpha, …) that work on every backend
  • Reusable specs & presets: chainable .with_*() helpers, plus save_preset / load_preset to a personal ~/.behaviz library
  • Visual data manipulators: jitter, smoothing, normalising, binning that add visual manipulations without changing the original data

Documentation

Installation

uv is recommended forfor dependency management.

uv pip install behaviz

Or add it directly through git:

uv add git+https://github.com/kaancet/behaviz.git
# or with pip
pip install git+https://github.com/kaancet/behaviz.git

Once installed, initialize the ~/.behaviz preset directory (not necessary but it's convenient for discoverability and manually dropping/editting preset files)

behaviz init

Quickstart

import numpy as np
import behaviz as bv

x = np.linspace(0, 2 * np.pi, 100)

# matplotlib is the default backend, nothing else to set up
fig, ax = bv.plot_line(x, np.sin(x), color="#349888", linewidth=3, label="sin(x)")

quickstart_example

Every plot function returns a (fig, ax) tuple, so you can keep customizing with the native backend objects if you ever need to.


Core concepts

The return contract

Function Returns
plot_line, plot_scatter, plot_bar, plot_step, plot_errorbar, plot_image,plot_fill_between, plot_pie, plot_hexbin (fig, ax)
plot_violin (fig, ax, vp)-vp["bodies"] holds the violin artists

When you pass an existing ax=, the plot is drawn onto it and the same axes is returned, so you can layer plots:

import numpy as np
import behaviz as bv

x = np.linspace(0, 2 * np.pi, 200)

fig, ax = bv.plot_line(x, np.sin(x), label="sin")
bv.plot_line(x, np.cos(x), ax=ax, label="cos", color="#D57106")  # same axes

quickstart_example

Switching backends

bv.set_renderer("matplotlib")   # default
bv.set_renderer("seaborn")      # matplotlib + seaborn themes
bv.set_renderer("bokeh")        # interactive HTML (great for dashboards)

The same plotting code works on all three. Only the display step differs for bokeh, which renders to HTML and needs an explicit show():

import behaviz as bv
from bokeh.plotting import show
from bokeh.io import output_notebook

bv.set_renderer("bokeh")
fig, ax = bv.plot_line(x, y)

output_notebook()   # in a Jupyter notebook
show(ax)            # for bokeh, `ax` *is* the figure

quickstart_example

How it works (architecture)

behaviz is intentionally layered so each piece stays small and testable:

  • spec/: plain dataclasses (PlotSpec, AxisSpec, FigureSpec) describing what a plot should look like, independent of any backend.
  • core/: the public plot functions. The simple (x, y) ones (plot_line, plot_scatter, plot_step) are generated from a single template in core_factory.py; richer ones are hand-written. A decorator (plot_function) handles figure creation, data= resolution, and spec application uniformly.
  • backends/: one Renderer per backend translating canonical calls into native matplotlib / seaborn / bokeh, plus an Overrider that routes keyword arguments and an opt-in HoverEngine.
  • A registry: validates at import that every plot type is fully implemented across all backends so that the gaps fail loudly during development, not at call time.

This is what lets the same call render on three backends and lets you reach any low-level property through a single high-level function.

Metadata

Release files for behaviz 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behaviz 0.6.4
File Size Uploaded Provenance Actions
behaviz-0.6.4.tar.gz 156.6 kB Without provenance Details for behaviz-0.6.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for behaviz 0.6.4
File Interpreter ABI Platform Actions
behaviz-0.6.4-py3-none-any.whl Python 3 none any Details for behaviz-0.6.4-py3-none-any.whl

Total release size: 298.0 kB

Release files / behaviz-0.6.4.tar.gz

Download URL behaviz-0.6.4.tar.gz
Size 156.6 kB
Tags Source
SHA-256 checksum
How to use checksums
61b0e4414cb17c64b0ecb6002f98006d81da0245d2f9185f22123727e4f56062
BLAKE2b-256 checksum
How to use checksums
8be430c86b17f7a4671fad14ef4ee245747f8fdacbab258845d6a3ce3323be77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / behaviz-0.6.4-py3-none-any.whl

Download URL behaviz-0.6.4-py3-none-any.whl
Size 141.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afe6c4fd2e6c2f322621d0e27b946eafacbf5a00838277deef9e796828f256c3
BLAKE2b-256 checksum
How to use checksums
ae89c06557ea3d023803d61e0455da8130ef31027a07001544300e32bbd50c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for behaviz 0.6.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page