Detailed reference document of the VCS colormap can be found at here. Colormap for example 4 provided by Karl Taylor.
Let's create your own VCS colormap.
The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux and Jiwoo Lee (Oct. 2017). This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
import vcs
import MV2
from matplotlib.colors import LinearSegmentedColormap
a = []
num_levels = 240
for i in range(0,num_levels):
a.append(i/float(num_levels))
for i in range(0,num_levels):
a.append(i/float(num_levels))
a = MV2.array(a)
a = MV2.reshape(a, (-1,num_levels))
a.id = 'dummy'
v = vcs.init()
vcs.listelements('colormap')vcs.listelements('colormap')
createcolormapv.createcolormap('my_cmap')
vcs.listelements('colormap')
setcolormap of VCSv.setcolormap('my_cmap')
for i in range(0,240):
v.setcolorcell(i,100,100,100)
setcolormap of VCSv.setcolorcell(0,0,0,0) # black
v.setcolorcell(1,50,50,50) # gray
v.setcolorcell(2,75,75,75) # silver
v.setcolorcell(3,100,100,100) # white
v.setcolorcell(4,50,0,0) # maroon
v.setcolorcell(5,100,0,0) # red
v.setcolorcell(6,50,50,0) # olive
v.setcolorcell(7,100,100,0) # yellow
v.setcolorcell(8,0,50,0) # green
v.setcolorcell(9,0,100,0) # lime
v.setcolorcell(10,0,50,50) # teal
v.setcolorcell(11,0,100,100) # aqua
v.setcolorcell(12,0,0,50) # navy
v.setcolorcell(13,0,0,100) # blue
v.setcolorcell(14,50,0,50) # purple
v.setcolorcell(15,100,0,100) # fuchsia
box.color_1 and box.color_2 of boxfill to set starting and ending colorsbox = v.createboxfill()
box.color_1 = 0
box.color_2 = 15
box.colormap = 'my_cmap'
v.plot(a,box)
cmap_name as string), and list of colors (colors as list of strings or tuples). User can define colors using either (1) named color of Matplotlib or (2) tuples of R, G, B numbers (0-1).LinearSegmentedColormap of matplotlib.colors, imported from the begining, stretchs given colors with smooth transition.matplotlib2vcs of vcs.colors convert given Matplotlib colormap to VCS colormap.def CreateOwnColormap(cmap_name, colors):
# Create a Matplotlib colomap
cm = LinearSegmentedColormap.from_list(cmap_name, colors, N=240)
# Convert Matplotlib colormap to VCS one
vcs_cmap = vcs.colors.matplotlib2vcs(cm, vcs_name=cmap_name)
return vcs_cmap
# Define my own colormap (name and sequentially varying colors)
cmap_name = 'cmap1'
colors = ['white','red','orange',
'yellow','green','blue','violet',
'purple','black']
CreateOwnColormap(cmap_name, colors)
box = v.createboxfill()
box.color_1 = 0
box.color_2 = 239
box.colormap = 'cmap1'
v.plot(a,box)
cmap_name2 = 'cmap2'
colors2 = [(1,0,0),(1,1,1),(0,0,1)] # red, white, blue
CreateOwnColormap(cmap_name2, colors2)
v.clear()
box.colormap = 'cmap2'
v.plot(a,box)
cmap_name3 = 'cmap3'
colors3 = ['white','lavender','royalblue','navy',
'darkviolet','darkred','tomato','darkorange',
'orange','yellow']
CreateOwnColormap(cmap_name3, colors3)
v.clear()
box.colormap = 'cmap3'
v.plot(a,box)
cmap_name4 = 'cmap4'
colors4 = [(99,93,60),
(99,80,40),
(99,60,20),
(99,40,11),
(99,0,0),
(51,0,0),
(44,11,62),
(0,40,99),
(20,60,99),
(40,80,99),
(60,93,99),
(80,99,99),
]
colors4 = MV2.divide(colors4,100.) # Convert range 0-100 to 0-1
CreateOwnColormap(cmap_name4, colors4)
v.clear()
box.colormap = 'cmap4'
v.plot(a,box)