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.
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 color 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')
>>> colorbar.set_ticks([0.0, 0.5, 1.0])
>>> plt.gca().add_artist(colorbar)
>>> plt.show()
Colorbar arguments
Here are parameters of the Colorbar class constructor.
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)
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: font properties of the label text, specified either as dict or fontconfig pattern (XML).
ticks: ticks location (default: minimal and maximal values)
ticklabels: a list of tick labels (same length as ticks argument)
ticklocation: location of the ticks: left or right for vertical oriented colorbar, bottom or top for horizontal oriented colorbar, or ``auto for automatic adjustment (right for vertical and bottom for horizontal oriented colorbar). (default: auto)
matplotlibrc parameters
Here are parameters that can be customized in the matplotlibrc file.
orientation: orientation, vertical or horizontal (default: vertical)
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)
ticklocation: location of the ticks (default: auto)
Release notes
0.4
Fix bug with matplotlib 3.x
Remove support for Python 2 and matplotlib < 3
Use pytest-mpl for testing
Use black code style
0.3.6
Fix deprecated usage of is_string_like
0.3.5
Fix: UserWarning This call to matplotlib.use() has no effect (#9)
Contributors
License
License under the BSD License, compatible with matplotlib.
Copyright (c) 2015-2017 Philippe Pinard
Metadata
Release files for matplotlib-colorbar 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| matplotlib-colorbar-0.4.0.tar.gz | 25.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matplotlib_colorbar-0.4.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 37.6 kB
Release files / matplotlib-colorbar-0.4.0.tar.gz
| Download URL | matplotlib-colorbar-0.4.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
031de56292734e6c12b2d3a62a3e883edbcb8a624fd27cf26ece8feb2e8b27d1
|
|
BLAKE2b-256 checksum How to use checksums |
fcd98281a2a377e24f2a9055c7db2ce0db1f6556cfb126f08780163d3250a50f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Release files / matplotlib_colorbar-0.4.0-py2.py3-none-any.whl
| Download URL | matplotlib_colorbar-0.4.0-py2.py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
799c44f64fbff6dc4933b5c0d7f75b9f9d8ccd2a7d55c0d801c3fa009be393c0
|
|
BLAKE2b-256 checksum How to use checksums |
bbc100f70038f9c87febf340fa4d2ba42429a630376e69716a7b1e21a0ce0a8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Security for matplotlib-colorbar 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.