pygrace.styles.colorbrewer module documentation

colorbrewer module

Parse the output of the the ColorBrewer website, which is a collection of color schemes for cartography.

http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer.html

The accompanying file (“colorbrewer.dat”), contains the entire content of the ColorBrewer output from the website (including the Apache-Style license). This module contains python code to parse the data file. To use this module, probably the user will just want to call the get_colors method of a color scheme. For example,

>>> from colorbrewer import * # this just imports the dictionary 'schemes'
>>> scheme = schemes['Set1']
>>> scheme.get_colors(7, 'hex')

will return the 7-color version of the ‘Set1’ color brewer color scheme, formatted as RGB hex strings.

For “Sequential” color schemes, the user can request more than the maximum enumerated number of colors for a scheme, and the color scheme linearly interpolates between the RGB values. For example,

>>> scheme = schemes['Blues']
>>> scheme.get_colors(50, 'int')

will return a list of RGB tuples, where each member of the tuple is an integer from 0-255.

Following is a list of the names and the maximum number of enumerated colors for each scheme:

Type Name Max N —- —- —– Diverging BrBG 11 Diverging PRGn 11 Diverging PiYG 11 Diverging PuOr 11 Diverging RdBu 11 Diverging RdGy 11 Diverging RdYlBu 11 Diverging RdYlGn 11 Diverging Spectral 11 Qualitative Accent 8 Qualitative Dark2 8 Qualitative Paired 12 Qualitative Pastel1 9 Qualitative Pastel2 8 Qualitative Set1 9 Qualitative Set2 8 Qualitative Set3 12 Sequential Blues 9 Sequential BuGn 9 Sequential BuPu 9 Sequential GnBu 9 Sequential Greens 9 Sequential Greys 9 Sequential OrRd 9 Sequential Oranges 9 Sequential PuBu 9 Sequential PuBuGn 9 Sequential PuRd 9 Sequential Purples 9 Sequential RdPu 9 Sequential Reds 9 Sequential YlGn 9 Sequential YlGnBu 9 Sequential YlOrBr 9 Sequential YlOrRd 9