-
Notifications
You must be signed in to change notification settings - Fork 12
Using customised colour ramps
A set of default colour ramps, derived from ColorBrewer, is available.
Even though viewer is certainly more a data analysis framework than a data visualisation tool, it is worth noting that additional colour ramps can be added. Keep in mind that the choice of the colour ramp used to visualise your data can have a huge impact on the analysis' output and the way differences in the data are perceived. A particularly vicious example is the infamous "rainbow" colour ramp (here's another classic read).
In viewer, colour ramps can be stored in a dedicated JSON file:
- The file is not sensitive to indentation
- Comments are allowed (using JavaScript synthax)
[
{
// A customised palette
"name" : "ColorCombo 378", // The name of the palette will be displayed in a drop-down list of the graphical interface
// The fields "author" and "comments" are not used (yet) by the interface, they are just optional metadata.
"author" : "ComboCentral",
"comments" : "http://www.colorcombos.com/color-schemes/221/ColorCombo221.html", // Some free text goes here. For example a contact or licence.
"type" : "Sequential", // The "type" field describes the kind of the palette
/*
Describes the colours used to generate the ramp
In this instance, RGB triplets are used
*/
"description" : {
"red" : "26 31 114 222 209",
"green" : "32 120 176 219 63",
"blue" : "44 114 149 167 49"
}
},
{
// Terrain palette for DEMs
"name" : "Terrain",
"author" : "",
"comments" : "Copied from the terrain.colors function in R",
"type" : "Sequential",
"description" : {
"red" : "0 45 99 160 230 232 235 237 240 242",
"green" : "166 182 198 214 230 195 178 180 201 242",
"blue" : "0 0 0 0 0 46 94 142 192 242"
}
},
{
/*
Palette colours can also be expressed
using hexadecimal codes
*/
"name" : "ColorCombo 221",
"author" : "ComboCentral",
"comments" : "http://www.colorcombos.com/color-schemes/221/ColorCombo221.html",
"type" : "Sequential",
"description" : {
"hex" : "#1C263C #313C53 #455268 #B6C0D2 #9CFF00 #FFFFFF"
}
}
]
The presence of a custom colour ramps file is tested through an environment variable named `VIEWER_EXTRA_RAMP`.
On Unix:
export TUIVIEW_EXTRA_RAMP="/usr/local/src/viewer/custompalettes.json"
If a (correctedly formatted) file is present, it is loaded, and additional colour ramps are added to the default set.