Dynamic color objects compatible with Matplotlib
Project description
Highlights
colorobjects are r, g, b, a tuples that support easy conversion to other color types (e.g. HSV, HLS, hexadecimal, or Matplotlib color names) and convenient transformation (e.g. adjust color lightness, hue, saturation, or alpha). Conversions are as convenient as c = somecolor.hsv, and transformations as easy as somecolor.lightness = c. And because a colorobject is just an extension of the list class, they can be passed directly to any Matplotlib plotting command.
colorlists are lists of colorobjects that allow you to easily modify or construct colormaps (see module colormaps) or cycle through lists of maximally distinct colors (see module discretecolors). Changing the brightness of a Matplotlib colormap can be as simple as cmap_adjust(mycolormap, ‘lighten’, 0.5) and you can even construct a colormap directly from any valid Matplotlib color name with:
colorlist(color('Aqua', 'name'), color('Gold', 'name')).LinearSegmentedColormap()
Some examples:
off-the-shelf Matplotlib colormap (‘BuPu’)
cmap_lighten()
cmap_darken()
cmap_adjust() used to rotate the hue
cmap_adjust() used to change the saturation
constructing an entirely new colormap using the Matplotlib color names ‘Aqua’ and ‘Gold’ as endpoints
Looking for a set of easily distinguishable colors? You could rely on one of the lists contained in custom_colorsets. Access to the color sets is through a statement such as:
colorobject.custom_colorsets.cartercarter_6
The included color sets are:
cartercarter_6: 6 high contrast colors from Carter and Carter (1982)
greenarmytage_26: 26 colors intended for use against a white background from Green-Armytage (2010)
tatarize_269: 269 colors from the author of the godsnotwheregodsnot blog
Installation
colorobject has only been tested in Python 2.7
Install through pip:
$ pip install colorobject
Requires the following non-standard libraries:
matplotlib
Because the preferred installation of matplotlib can vary depending on the operating system, matplotlib will not automatically be installed as a dependency. Instead, installation will raise an exception if matplotlib cannot be found in the pythonpath. In this case, please install matplotlib via your preferred method, most of which are explained by matplotlib
Bonus!
Also included are a set of custom Matplotlib colormaps. These colormaps were designed to have every color in the colormap be clearly distinguishable against a white background. Also, the ordering of the colors from low to high is intended to be as intuitive as possible and there are no sudden peaks in the lightness or hue. Access to the colormaps is through a statement such as:
colorobject.custom_colormaps.sparse2dense
The intended use for these colormaps is:
cool2hot: temperature or heat
deep2shallow: bathymetry maps
dirty2clean: environmental condition or degredation
sparse2dense: density maps
low2high: generic
Changelog
- 0.8.1 (DECEMBER/02/2014)
Moved custom color sets from module discretecolors to named tuple custom_colorsets in module data. Access is through a statement such as colorobject.custom_colorsets.cartercarter_6
Added custom color maps with named tuple custom_colormaps to module data. Access is through a statement such as colorobject.custom_colormaps.sparse2dense
0.8.0 (DECEMBER/01/2014)
First release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file colorobject-0.8.1.tar.gz
.
File metadata
- Download URL: colorobject-0.8.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adbd8f3c2447937141f845922ccb77dc9e12167134e1d778353b390d0b9d765b |
|
MD5 | 3c36907ff6c8072b72b77b7ac0f7fbe9 |
|
BLAKE2b-256 | 29f6c8d13c2346e627583b86acc120f8c0af251af84c28daa8e300de029def64 |
File details
Details for the file colorobject-0.8.1-py2-none-any.whl
.
File metadata
- Download URL: colorobject-0.8.1-py2-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 902a6d30ab8243e7a75c070010e4995d1707e0b47257b7d361774c4679804099 |
|
MD5 | 861cc9d943c02cb79fc3a57bcbc4e18f |
|
BLAKE2b-256 | 54ffd3c3cdff7cf1a45c73b6abd90331020a6f992ba3881321c7d746505d1221 |