plotly_tools.
cmap_plt2js
(cmap, cmin=0.0, cmax=1.0, Ncols=None)[source]¶Converts Matplotlib colormaps to JavaScript color-scales
Parameters: | cmap : Matplotlib colormap
cmin : float
cmax : float
Ncols : int
|
---|---|
Returns: | cscale : list
|
See also
Notes
None
Examples
The following command converts and down-samples the jet colormap in the range [0.1, 1] to a JavaScript color-scale with 12 components
>>> import matplotlib.pyplot as plt
>>> cscale = cmap_plt2js(plt.cm.jet,cmin=0.1,Ncols=12)
>>> cscale
[[0.0, 'rgb(0,0,241)'],
[0.090909090909090912, 'rgb(0,56,255)'],
[0.18181818181818182, 'rgb(0,140,255)'],
[0.27272727272727271, 'rgb(0,224,251)'],
[0.36363636363636365, 'rgb(64,255,183)'],
[0.45454545454545459, 'rgb(131,255,115)'],
[0.54545454545454541, 'rgb(199,255,48)'],
[0.63636363636363635, 'rgb(255,222,0)'],
[0.72727272727272729, 'rgb(255,145,0)'],
[0.81818181818181823, 'rgb(255,67,0)'],
[0.90909090909090917, 'rgb(218,0,0)'],
[1.0, 'rgb(128,0,0)']]