A modular and flexible graphing library
Project description
behaviz
A modular, multi-backend plotting library that gets you from raw data to a clean, clear and reproducible figures - fast.
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:
- Consistent, reproducible plots for similar data: describe a plot once with a
spec, reuse it everywhere. - High-level calls with low-level control: simple functions like
plot_lineandplot_scatterthat 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, plussave_preset/load_presetto a personal~/.behavizlibrary - 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)")
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
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
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 incore_factory.py; richer ones are hand-written. A decorator (plot_function) handles figure creation,data=resolution, and spec application uniformly.backends/: oneRendererper backend translating canonical calls into native matplotlib / seaborn / bokeh, plus anOverriderthat routes keyword arguments and an opt-inHoverEngine.- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file behaviz-0.5.10.tar.gz.
File metadata
- Download URL: behaviz-0.5.10.tar.gz
- Upload date:
- Size: 133.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd12382c9e06acdd9e826f60dd202c1d79d89d3b7256bd1d26dd0a170c6b2e75
|
|
| MD5 |
ae8824d67f15e20804d88e5118e5ff9d
|
|
| BLAKE2b-256 |
4c298cad47dc74833a637dbeafb8323b7436e032d54d26d4e607018964a69c2c
|
File details
Details for the file behaviz-0.5.10-py3-none-any.whl.
File metadata
- Download URL: behaviz-0.5.10-py3-none-any.whl
- Upload date:
- Size: 119.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84607e690ddec0716832ba8ff72e47bc575010ea15a0c58727a0e1996f7c553
|
|
| MD5 |
25a30bd5bf88464733d6cd8a8bbf4010
|
|
| BLAKE2b-256 |
7edff54cbf815c39e9e50e88b94817db8f2b63f5a3ef5524002de860e72a2daf
|