Skip to main content

Python library for plotting bivariate choropleth maps

Project description

bivario

Python library for plotting bivariate choropleth maps in Matplotlib and Folium.


GitHub Checks GitHub Workflow Status - PROD pre-commit.ci status CodeFactor Grade Codecov Package version Supported Python versions PyPI - Downloads

Installation

With pip:

pip install bivario

With uv:

uv add bivario

Usage


Example of a Folium map in light and dark modes.

Simple Folium map:

from bivario import explore_bivariate_data
from bivario.example_data import nyc_bike_trips

explore_bivariate_data(
    nyc_bike_trips(), "morning_starts", "morning_ends"
)

In dark mode:

from bivario import explore_bivariate_data
from bivario.example_data import nyc_bike_trips

explore_bivariate_data(
    nyc_bike_trips(),
    column_a="morning_starts",
    column_b="morning_ends",
    dark_mode=True, # default is False
)

Use other palette:

from bivario import explore_bivariate_data
from bivario.example_data import nyc_bike_trips

explore_bivariate_data(
    nyc_bike_trips(),
    column_a="morning_starts",
    column_b="morning_ends",
    cmap="bubblegum"
)

Set numerical mode (disable bucketing):

[!NOTE] By default, map is created using Mapclassify library with NaturalBreaks method to split data into 5 categories. Method and number of buckets can be changed or disabled completely.

from bivario import explore_bivariate_data
from bivario.example_data import nyc_bike_trips

explore_bivariate_data(
    nyc_bike_trips(),
    column_a="morning_starts",
    column_b="morning_ends",
    dark_mode=True,
    cmap="late_sunset",
    scheme=False, # or set to None
    legend_size_px=300,
)


Example of a Folium map in a numerical mode.

Bivariate colourmaps

Palettes in bivario are created by blending 2 or 4 colours in a 2D space using OKLab colour space. The operations on input and output are done in RGB, an internally are transformed into OKLab values using colour-science library.

bivario has 4 modes of Bivariate colourmaps:

AccentsBivariateColourmap - defined by two accent colours and a light and a dark colour.


CornersBivariateColourmap - defined by 4 corner colours (accent a/b, low value and high value)


MplCmapBivariateColourmap - defined by 2 Matplotlib colourmaps along axis X and Y


NamedBivariateColourmap - can load predefined palette from string name


Available palettes


You can load these palettes by passing a string name to the cmap attribute, or load a NamedBivariateColourmap object:

cmap = NamedBivariateColourmap("coral_ocean")

# You can call it similar to Matplotlib Colormap object
rgb_values = cmap(values_a=[0, 1], values_b=[0, 1])

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

bivario-0.2.0.tar.gz (93.7 kB view details)

Uploaded Source

Built Distribution

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

bivario-0.2.0-py3-none-any.whl (93.9 kB view details)

Uploaded Python 3

File details

Details for the file bivario-0.2.0.tar.gz.

File metadata

  • Download URL: bivario-0.2.0.tar.gz
  • Upload date:
  • Size: 93.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for bivario-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5a2223f5f12947e32f72c5a4c70fca7193377d8db63333e1f372598f7812b04
MD5 5f499405093b98d4afb43e5aa77712de
BLAKE2b-256 062141b2b5018b27a6dced313ab5991a46efb4c80e10379e9c4523bdb9652d13

See more details on using hashes here.

File details

Details for the file bivario-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bivario-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for bivario-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00c87846a8324200b2f31aad4767b6094766db72c88f51f273b3abe0fd6998ab
MD5 c14b873865225d26180dc1f2b506992b
BLAKE2b-256 f80d37d4658d37d0a871b2fdd168d4720e897f9d973e34693a983e9a631189ad

See more details on using hashes here.

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