# Creates a symmetric continuous colormap with 3 keys
# The color range is -10 to 10
# The colors are 'blue','white','red' for these keys
pal <- create_colormap(
gtype = "volume", dtype = "continuous",
key = c(1,2,3), value = c(-10,0,10),
color = c('blue','white','red'))
print( pal )
# ---------------- Get colormap key from a value ------------
# returns key index starting from
pal$get_key( -10 )
# nearest value
pal$get_key( 2 )
# set threshold, key is now 0 (no color)
pal$get_key( 2, max_delta = 1 )
# ---------------- Save and load ----------------
f <- tempfile( fileext = '.json' )
save_colormap( pal, f )
cat(readLines(f), sep = '\n')
load_colormap(f)
Run the code above in your browser using DataLab