Assigning Colors in Deephaven

Colors can be assigned in Deephaven tables or plots using strings or by using color objects.

Applying Color with String Methods

Named Color Values

There are 280 predefined color values available in Deephaven. (See: Named Colors Chart.) These predefined colors are referred to by their names, which must be typed in capital letters.

Because these values are considered strings, they must be enclosed in quotes. If the named color values are to be used within another string (i.e., a string within a string), the name must be enclosed in backticks. See examples below:

Examples

pointColor("SKYBLUE")

formatColumns("Date=`SKYBLUE`")

HEX (Hexadecimal)

Hexadecimal values are specified with three values that correspond to RRGGBB. Each value [RR (red), GG (green) and BB (blue)] are hexadecimal integers between 00 and FF, and they specify the intensity of the color. All Hex values are preceded with a pound sign, e.g., #0099FF.

Because these values are considered strings, they must be enclosed in quotes. If the HEX color values are to be used within another string (i.e., a string within a string), the name must be enclosed in backticks. See examples below:

Examples

pointColor("#87CEFA")

formatColumns("Date=`#87CEFA`")

Applying Color with Color Objects

Color objects can be created using any of the color models listed below.

  • Predefined Color Variables
  • String Values
  • RGB (Red, Green, Blue)
  • RGBA (Red, Green, Blue, Alpha)
  • HSL (Hue, Saturation, Lightness)
  • HSLA (Hue, Saturation, Lightness, Alpha)

Predefined Color Variables

Deephaven offers a set of predefined color variables that can be used as color objects in your queries.  The names of these color variables take the following form:  COLOR_<NAMEDCOLOR>. The value used for <NAMEDCOLOR> can be any of the named color values described above. Examples include: COLOR_RED, COLOR_GREEN, COLOR_VIVID_PURPLE, etc. As with the named color values, the predefined color variables must be typed in capital letters.

Examples

lineColor(COLOR_SKYBLUE)

formatColumns("Date=COLOR_SKYBLUE")

String Values

Named color values and HEX color values can also be converted into color objects in Deephaven by enclosing their values (as strings) into the argument of the color method. The syntax follows:

color(`<COLORNAME>`)

color(`#RRGGBB`)

Examples

lineColor(color(`SKYBLUE`))

lineColor(color(`#87CEFA`))

formatColumns("Date=color(`SKYBLUE`)")

formatColumns("Date=color(`#87CEFA`)")

RGB (Red, Green, Blue)

RGB values are represented numerically with comma-separated values for red, green and blue respectively, with each value expressed as integers in the range 0-255 or floats in the range 0-1.

RGB color values can be converted into color objects in Deephaven by enclosing their values into the argument of the colorRGB method. The syntax follows:

colorRGB(int r, int g, int b)

colorRGB(float r, float g, float b)

Examples

lineColor(colorRGB(135, 206, 250))

formatColumns("Date=colorRGB(135, 206, 250)")

RGBA (Red, Green, Blue, Alpha)

The RGBA color model is based on RGB. However, RGBA provides an option for a fourth value to specify alpha (transparency). As with RGB, the numeric values can be specified using floats or ints. The numeric ranges for RGB remain the same. The alpha channel can range from 0 (fully transparent) to 255 (fully opaque) for ints, and 0.0 to 1.0 for floats.

RGBA color values can be converted into color objects in Deephaven by enclosing their values into the argument of the colorRGB method. The syntax follows:

colorRGB(int r, int g, int b, int a)

colorRGB(float r, float g, float b, float a)

Examples

lineColor(colorRGB(255,0,0,100))

formatColumns("Date=colorRGB(135, 206, 250, 50)")

HSL (Hue, Saturation, Lightness)

HSL values are represented numerically with comma-separated values for hue, saturation and lightness respectively. Hue is the degree on the color wheel, and can range from 0 to 360. Saturation is the percentage of value. Lightness is also a percentage, with 0% being black, and 100% being white. The numeric values for HSL can only be specified using floats.

HSL color values can be converted into color objects in Deephaven by enclosing their values into the argument of the colorHSL method. The syntax follows:

colorHSL(float h, float s, float l)

Examples

lineColor(colorHSL(0.56, 0.92, 1.75))

formatColumns("Date=colorHSL(0.56, 0.92, 1.75)")

HSLA (Hue, Saturation, Lightness, Alpha)

The HSLA color model is based on HSL. However, HSLA provides an option for a fourth value to specify alpha (transparency). As with HSL, the numeric values must be specified using floats. The numeric ranges for HSL remain the same. The alpha channel can range from 0.0 (fully transparent) to 1.0 (fully opaque).

HSLA color values can be converted into color objects in Deephaven by enclosing their values into the argument of the colorHSL method. The syntax follows:

colorHSL(float h, float s, float l float a)

Examples

lineColor(colorHSL(0.56, 0.92, 1.75, 0.75))

formatColumns("Date=colorHSL(0.56, 0.92, 1.75, 0.5)")


Last Updated: 16 February 2021 18:07 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved