Skip to main content

Port of the R farrowandball palette implementation.

Project description

Farrow&Ball Matplotlib

pypi Badge

This is a python port for the matplotlib library of the R Package for ggplot2.

spec palette charts tonka palette charts

The style for the charts is provided in the styles folder


A python version >= 3 is required.

pip install farrow-and-ball


The usage is quite simple:

from farrow_and_ball import *
import numpy as np
import matplotlib.pyplot as plt

# Define a gray scale image
x = np.arange(0, np.pi, 0.1)
y = np.arange(0, 2 * np.pi, 0.1)
X, Y = np.meshgrid(x, y)
Z = np.cos(X) * np.sin(Y) * 10

# Get the color map
cmap = build_colormap(DivergentPalette.DAY, True)

# Draw image
plt.imshow(Z, origin="lower", cmap=cmap)

One can also directly get the color map definition as a list of strings with farrow_and_ball.get_palette(DivergentPalette.DAY) or an interpolated one with farrow_and_ball.get_interpolated_palette(DivergentPalette.DAY, num_classes).


The palettes are organized in Enums:

class SpectralPalette(Enum):
    DEEPSPEC = "deepspec"
    SPEC = "spec"
    LIGHTSPEC = "lightspec"
    LIGHTERSPEC = "lighterspec"

class DivergentPalette(Enum):
    DAY = "day"
    DAYLONG = "daylong"
    ARMY = "army"
    MONO = "mono"

class BaseColorPalette(Enum):
    PINKS = "pinks"
    PINKS_VAR = "pinks2"
    REDS = "reds"
    YELLOWS = "yellows"
    GREENS = "greens"
    GREENS_VAR = "greens2"
    BLUES = "blues"
    BLUES_VAR = "blues2"

class MiscPalette(Enum):
    TONKA = "tonka"
    BELLSPOUT = "bellsprout"
    DOCKERS = "dockers"
    FRUITYPEBBLES = "fruitypebbles"

One can also directly enter the name as a string, e.g. build_colormap("day", True).

Color Maps


Spectral Palette Divergent Palette Base Color Palette Misc Palette


Spectral Palette Divergent Palette Base Color Palette Misc Palette

Project details

Download files

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

Files for farrow-and-ball, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size farrow_and_ball-0.0.3-py3-none-any.whl (6.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size farrow-and-ball-0.0.3.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page