From 82c355a38f3f58198f2a9269c3e10d6cd7b7af80 Mon Sep 17 00:00:00 2001
From: Pim Schellart <P.Schellart@astro.ru.nl>
Date: Fri, 9 Sep 2011 16:37:47 +0200
Subject: [PATCH] Added cubehelix monotonically increasing colorscheme (developed by D.A. Green) to matplotlib colorscheme list.

---
 lib/matplotlib/_cm.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py
index 5bea519..515e104 100644
--- a/lib/matplotlib/_cm.py
+++ b/lib/matplotlib/_cm.py
@@ -46,6 +46,18 @@ _prism_data = {
         'blue': lambda x: -1.1 * np.sin((x * 20.9) * np.pi),
 }
 
+# cubehelix parameters
+_gamma_cubehelix = 1.0
+_s_cubehelix = 0.5
+_r_cubehelix = -1.5
+_h_cubehelix = 1.0
+
+_cubehelix_data = {
+        'red': lambda x: x**_gamma_cubehelix + (_h_cubehelix * x**_gamma_cubehelix * (1 - x**_gamma_cubehelix) / 2) * (-0.14861 * np.cos(2 * np.pi * (_s_cubehelix / 3 + _r_cubehelix * x)) + 1.78277 * np.sin(2 * np.pi * (_s_cubehelix / 3 + _r_cubehelix * x))),
+        'green': lambda x: x**_gamma_cubehelix + (_h_cubehelix * x**_gamma_cubehelix * (1 - x**_gamma_cubehelix) / 2) * (-0.29227 * np.cos(2 * np.pi * (_s_cubehelix / 3 + _r_cubehelix * x)) - 0.90649 * np.sin(2 * np.pi * (_s_cubehelix / 3 + _r_cubehelix * x))),
+        'blue': lambda x: x**_gamma_cubehelix + (_h_cubehelix * x**_gamma_cubehelix * (1 - x**_gamma_cubehelix) / 2) * (1.97294 * np.cos(2 * np.pi * (_s_cubehelix / 3 + _r_cubehelix * x))),
+}
+
 _bwr_data = ((0.0, 0.0, 1.0), (1.0, 1.0, 1.0), (1.0, 0.0, 0.0))
 _brg_data = ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0))
 
@@ -1575,6 +1587,7 @@ datad = {
     'brg':    _brg_data,
     'cool':   _cool_data,
     'copper': _copper_data,
+    'cubehelix': _cubehelix_data,
     'flag':   _flag_data,
     'gnuplot': _gnuplot_data,
     'gnuplot2': _gnuplot2_data,
-- 
1.7.2.3

