ppinard / matplotlib-colorbar

Provides a new artist for matplotlib to display a colorbar
BSD 2-Clause "Simplified" License
7 stars 3 forks source link

matplotlib-colorbar

.. image:: https://img.shields.io/github/workflow/status/ppinard/matplotlib-colorbar/CI :alt: GitHub Workflow Status

.. image:: https://img.shields.io/pypi/v/matplotlib-colorbar :alt: PyPI

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.

.. image:: 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 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.

matplotlibrc parameters

Here are parameters that can be customized in the matplotlibrc file.

Release notes

0.4 ^^^

0.3.6 ^^^^^

0.3.5 ^^^^^

Contributors

@cphyc <https://github.com/cphyc> and @jnth <https://github.com/jnth>

License

License under the BSD License, compatible with matplotlib.

Copyright (c) 2015-2017 Philippe Pinard