Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6001274

Browse files
committed
adds documentation and example plots
1 parent 07d25f3 commit 6001274

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

tutorials/colors/colormaps.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
middle value, such as topography or when the data deviates around
5757
zero.
5858
59-
3. Qualitative: often are miscellaneous colors; should be used to
59+
3. Wrapping: change in lightness of two different colors that meet in
60+
the middle and beginning/end at an unsaturated color; should be
61+
used for values that wrap around at the endpoints, such as phase
62+
angle, wind direction, or time of day.
63+
64+
4. Qualitative: often are miscellaneous colors; should be used to
6065
represent information which does not have ordering or
6166
relationships.
6267
"""
@@ -124,6 +129,26 @@
124129
'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
125130
'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']
126131

132+
###############################################################################
133+
# Wrapping
134+
# --------
135+
#
136+
# For Wrapping maps, we want to start and end on the same color, and meet a
137+
# symmetric center point in the middle. :math:`L^*` should change monotonically
138+
# from start to middle, and inversely from middle to end. It should be symmetric
139+
# on the increasing and decreasing side, and only differ in hue. At the ends and
140+
# middle, :math:`L^*` will reverse direction, which should be smoothed in
141+
# :math:`L^*` space to reduce artifacts. See [kovesi-colormaps]_ for more
142+
# information on the design of wrapping maps.
143+
#
144+
# The often-used HSV colormap is included in this set of colormaps, although it
145+
# is not symmetric to a center point. Additionally, the :math:`L^*` values vary
146+
# widely throughout the colormap, making it a poor choice for representing data
147+
# for viewers to see perceptually. See an extension on this idea at
148+
# [mycarta-jet]_.
149+
150+
cmaps['Wrapping'] = ['twilight', 'sunlight', 'hsv']
151+
127152
###############################################################################
128153
# Qualitative
129154
# -----------
@@ -158,7 +183,7 @@
158183

159184
cmaps['Miscellaneous'] = [
160185
'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
161-
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv',
186+
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',
162187
'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar']
163188

164189
###############################################################################
@@ -206,13 +231,13 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
206231

207232
# Number of colormap per subplot for particular cmap categories
208233
_DSUBS = {'Perceptually Uniform Sequential': 5, 'Sequential': 6,
209-
'Sequential (2)': 6, 'Diverging': 6, 'Qualitative': 4,
210-
'Miscellaneous': 6}
234+
'Sequential (2)': 6, 'Diverging': 6, 'Wrapping': 3,
235+
'Qualitative': 4, 'Miscellaneous': 6}
211236

212237
# Spacing between the colormaps of a subplot
213238
_DC = {'Perceptually Uniform Sequential': 1.4, 'Sequential': 0.7,
214-
'Sequential (2)': 1.4, 'Diverging': 1.4, 'Qualitative': 1.4,
215-
'Miscellaneous': 1.4}
239+
'Sequential (2)': 1.4, 'Diverging': 1.4, 'Wrapping': 1.4,
240+
'Qualitative': 1.4, 'Miscellaneous': 1.4}
216241

217242
# Indices to step through colormap
218243
x = np.linspace(0.0, 1.0, 100)
@@ -388,6 +413,7 @@ def plot_color_gradients(cmap_category, cmap_list):
388413
# .. [list-colormaps] https://gist.github.com/endolith/2719900#id7
389414
# .. [mycarta-banding] https://mycarta.wordpress.com/2012/10/14/the-rainbow-is-deadlong-live-the-rainbow-part-4-cie-lab-heated-body/
390415
# .. [mycarta-jet] https://mycarta.wordpress.com/2012/10/06/the-rainbow-is-deadlong-live-the-rainbow-part-3/
416+
# .. [kovesi-colormaps] https://arxiv.org/abs/1509.03700
391417
# .. [bw] http://www.tannerhelland.com/3643/grayscale-image-algorithm-vb6/
392418
# .. [colorblindness] http://www.color-blindness.com/
393419
# .. [vischeck] http://www.vischeck.com/vischeck/

0 commit comments

Comments
 (0)