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.

Download files

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

Source Distribution

behaviz-0.5.15.tar.gz (146.6 kB view details)

Uploaded Source

Built Distribution

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

behaviz-0.5.15-py3-none-any.whl (134.5 kB view details)

Uploaded Python 3

File details

Details for the file behaviz-0.5.15.tar.gz.

File metadata

  • Download URL: behaviz-0.5.15.tar.gz
  • Upload date:
  • Size: 146.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for behaviz-0.5.15.tar.gz
Algorithm Hash digest
SHA256 7dfed8dbebbad2ce490895317f2aecb0a4cdf5160e1361b1d17597d89bd5fda2
MD5 905dee4aedd16d3a60ff1f724c5ac412
BLAKE2b-256 feeeb58071db4f853f956edfaffd93a8b41d4a8e46fc33afc2255b1e5bb89773

See more details on using hashes here.

File details

Details for the file behaviz-0.5.15-py3-none-any.whl.

File metadata

  • Download URL: behaviz-0.5.15-py3-none-any.whl
  • Upload date:
  • Size: 134.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for behaviz-0.5.15-py3-none-any.whl
Algorithm Hash digest
SHA256 9e322fd7cf901e40b89f151e7f25d095bb595d357d1d0d7231ac332dbc1c7940
MD5 de669e43b1bf43ed1b42c3905532553d
BLAKE2b-256 37f4f65001afaf633f162b489cc75b381fb569500f8c7828652a8cd79bfec2f1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.18

2 files

0.5.17

2 files

0.5.16

2 files

This release

0.5.15 This release

2 files

0.5.14

2 files

0.5.13

2 files

0.5.11

2 files

0.5.10

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.0

2 files

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