Skip to main content
https://travis-ci.org/ppinard/matplotlib-colorbar.svg https://badge.fury.io/py/matplotlib-colorbar.svg

Provides a new artist for matplotlib to display a colorbar, instead of an axis as it is the default in matplotlib. The position of the colorbar artist can be decided as for the legend.

https://raw.githubusercontent.com/ppinard/matplotlib-colorbar/master/doc/example1.png

The artist supports customization either directly from the ColorBar object or from the matplotlibrc.

Installation

Easiest way to install using pip:

$ pip install matplotlib-colorbar

For development installation from the git repository:

$ git clone git@github.com:ppinard/matplotlib-colorbar.git
$ pip install -e matplotlib-colorbar

Example

Here is an example how to add a scale bar:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import matplotlib.cbook as cbook
>>> from matplotlib_colorbar.colorbar import ColorBar
>>> plt.figure()
>>> data = np.array(plt.imread(cbook.get_sample_data('grace_hopper.png')))
>>> mappable = plt.imshow(data[...,0], cmap='viridis')
>>> colorbar = ColorBar(mappable, location='lower left')
>>> plt.gca().add_artist(colorbar)
>>> plt.show()

matplotlibrc parameters

Here are parameters that can either be customized in the constructor of the ColorBar class or in the matplotlibrc file.

  • mappable: scalar mappable object which implements the methods get_cmap and get_array (default: None, the mappable can be specified later)

  • label: label on top of the color bar (default: None, no label is shown)

  • orientation: orientation, vertical or horizontal (default: vertical)

  • nbins: number of color division in the color bar (default: or 50)

  • length_fraction: length of the color bar as a fraction of the axes’s width (horizontal) or height (vertical) depending on the orientation (default: 0.2)

  • width_fraction: width of the color bar as a fraction of the axes’s height (horizontal) or width (vertical) depending on the orientation (default: 0.02)

  • location: a location code (same as legend) (default: upper right)

  • pad: fraction of the font size (default: 0.2)

  • border_pad: fraction of the font size (default: 0.1)

  • sep: separation between color bar and label in points (default: 5)

  • frameon: if True, will draw a box around the color bar (default: True)

  • color: color for the tick text and label (default: k)

  • box_color: color of the box (if frameon) (default: w)

  • box_alpha: transparency of box (default: 1.0)

  • font_properties: a matplotlib.font_manager.FontProperties instance, optional sets the font properties for the label text

  • ticks: ticks location (default: minimal and maximal values)

  • ticklabels: a list of tick labels (same length as ticks argument)

License

License under the BSD License, compatible with matplotlib.

Copyright (c) 2015-2016 Philippe Pinard and collaborators

Download files

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

Source Distribution

matplotlib-colorbar-0.2.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

matplotlib_colorbar-0.2.0-py2.py3-none-any.whl (11.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file matplotlib-colorbar-0.2.0.tar.gz.

File metadata

File hashes

Hashes for matplotlib-colorbar-0.2.0.tar.gz
Algorithm Hash digest
SHA256 49ffe222eafd1f342d1d8711b6c8c32ef986df78e27cac67bd630942e6f8d4a4
MD5 3d81fa4936e1825b40b453ef22e97fe1
BLAKE2b-256 2136b22a2873b70723bffee6fc7d160fcf7a1faeb17d5c24ebd8ab5c9102a18d

See more details on using hashes here.

File details

Details for the file matplotlib_colorbar-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for matplotlib_colorbar-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fb7fa0ad3cc27e0cd2a8ba81559b309d435c5410087ea2358848dbdc102fdca2
MD5 d7ba61a7a7926ad223489c94f5d3c636
BLAKE2b-256 19b2ae3f5f303695603cf9957aafbb03317ed5e1b96bd7352e1be4843196e4ed

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 Sentry Error logging StatusPage Status page