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.6.0.tar.gz (154.9 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.6.0-py3-none-any.whl (140.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: behaviz-0.6.0.tar.gz
  • Upload date:
  • Size: 154.9 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.6.0.tar.gz
Algorithm Hash digest
SHA256 f0435b7da1777b702ac4008428114b7caa55e5229c3959a6d069823d4913681f
MD5 5c7f26a11b95d8edee1e4df9cd9a4958
BLAKE2b-256 96e7572bc9a08d209e6f68f39cdd74cb77c79601022a40b9e0a6a844b848d522

See more details on using hashes here.

File details

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

File metadata

  • Download URL: behaviz-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 140.4 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3c727b07f6391709f384ce611194b9e565b6ab2b92a30f1ed9db462696933d
MD5 d16de60b148ebf25de46f78e4de1ba69
BLAKE2b-256 0d53f3d819973657939d1e880aa82fe606881b15e5bbc6438834927a42d74fac

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

This release

0.6.0 This release

2 files

0.5.18

2 files

0.5.17

2 files

0.5.16

2 files

0.5.15

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