Package: matplotlib-colorbar
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 theColorbarobject or
from the matplotlibrc.InstallationEasiest way to install usingpip:$ pip install matplotlib-colorbarFor development installation from the git repository:$ git clone git@github.com:ppinard/matplotlib-colorbar.git
$ pip install -e matplotlib-colorbarExampleHere 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 argumentsHere are parameters of theColorbarclass constructor.mappable: scalar mappable object which implements the methodsget_cmapandget_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,verticalorhorizontal(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 (ifframeon) (default:w)box_alpha: transparency of box (default:1.0)font_properties: font properties of the label text, specified either as dict orfontconfigpattern (XML).ticks: ticks location (default: minimal and maximal values)ticklabels: a list of tick labels (same length asticksargument)ticklocation: location of the ticks:leftorrightfor vertical oriented colorbar,bottomortop for horizontal oriented colorbar, or ``autofor automatic adjustment (rightfor vertical andbottomfor horizontal oriented colorbar). (default:auto)matplotlibrc parametersHere are parameters that can be customized in the matplotlibrc file.orientation: orientation,verticalorhorizontal(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 (ifframeon) (default:w)box_alpha: transparency of box (default:1.0)ticklocation: location of the ticks (default:auto)Release notes0.4Fix bug with matplotlib 3.xRemove support for Python 2 and matplotlib < 3Use pytest-mpl for testingUse black code style0.3.6Fix deprecated usage of is_string_like0.3.5Fix: UserWarning This call to matplotlib.use() has no effect (#9)Contributors@cphycand@jnthLicenseLicense under the BSD License, compatible with matplotlib.Copyright (c) 2015-2017 Philippe Pinard