Skip to content

Colours

For a list of available colours, run the following within Analyst:

    8 _ key .gg.colour

A colour is a 3-byte array of the form 0xRRGGBB. For example, full red would be 0xff0000. In general, wherever a colour is expected, either a pre-defined colours from this module can be used, or a custom 3-byte array.

.gg.colour.COLOURS

Purely exists for documentation. See below for a list of built-in colours.

Example: Generate list of built-in colours

      n:key[.gg.colour] where 4h = type each value .gg.colour;
      c: .gg.colour n;
      sortedIndices: (){if[y in x; y+:1]; x,y}/c?.gg.colour.sort c;
      t: ([]ii:0;ii2:-0.55; y:til count n;y2:1+til count n; ty: 0.5+til count n; n:n sortedIndices;c:c sortedIndices);


     .qp.theme[.gg.theme.transparent].qp.title["Built-in Colours (.gg.colour.*)"]
     .qp.theme[`legend_use`axis_use_x`axis_use_y!(0b; 0b; 0b)]
     .qp.stack (
          .qp.interval[t; `ii; `y ;`y2]
              .qp.s.scale[`x; .gg.scale.limits[-1 0] .gg.scale.linear]
              , .qp.s.scale[`y; .gg.scale.limits[(0;count n)] .gg.scale.linear]
              , .qp.s.aes[`fill; `n]
              , .qp.s.scale[`fill; .gg.scale.colour.cat n[sortedIndices]!c sortedIndices];
          .qp.text[t; `ii2; `ty; `n; .qp.s.textalign`right])

Image

.gg.colour.brewer

Return the brewer scale for the given palette and colour count

Parameter(s):

Name Type Description
palette symbol palette name (see example below)
n long colour count (see example below)

Returns:

Name Type Description
byte[][] list of colours

Example: Available palettes are

 YlGn    | 3 4 5 6 7 8 9
 YlGnBu  | 3 4 5 6 7 8 9
 GnBu    | 3 4 5 6 7 8 9
 BuGn    | 3 4 5 6 7 8 9
 PuBuGn  | 3 4 5 6 7 8 9
 PuBu    | 3 4 5 6 7 8 9
 BuPu    | 3 4 5 6 7 8 9
 RdPu    | 3 4 5 6 7 8 9
 PuRd    | 3 4 5 6 7 8 9
 OrRd    | 3 4 5 6 7 8 9
 YlOrRd  | 3 4 5 6 7 8 9
 YlOrBr  | 3 4 5 6 7 8 9
 Purples | 3 4 5 6 7 8 9
 Blues   | 3 4 5 6 7 8 9
 Greens  | 3 4 5 6 7 8 9
 Oranges | 3 4 5 6 7 8 9
 Reds    | 3 4 5 6 7 8 9
 Greys   | 3 4 5 6 7 8 9
 PuOr    | 3 4 5 6 7 8 9 10 11
 BrBG    | 3 4 5 6 7 8 9 10 11
 PRGn    | 3 4 5 6 7 8 9 10 11
 PiYG    | 3 4 5 6 7 8 9 10 11
 RdBu    | 3 4 5 6 7 8 9 10 11
 RdGy    | 3 4 5 6 7 8 9 10 11
 RdYlBu  | 3 4 5 6 7 8 9 10 11
 Spectral| 3 4 5 6 7 8 9 10 11
 RdYlGn  | 3 4 5 6 7 8 9 10 11
 Accent  | 3 4 5 6 7 8
 Dark2   | 3 4 5 6 7 8
 Paired  | 3 4 5 6 7 8 9 10 11 12
 Pastel1 | 3 4 5 6 7 8 9
 Pastel2 | 3 4 5 6 7 8
 Set1    | 3 4 5 6 7 8 9
 Set2    | 3 4 5 6 7 8
 Set3    | 3 4 5 6 7 8 9 10 11 12

.gg.colour.cat10

10 distinct colours

.gg.colour.cat20

20 distinct colours (10 colours in lightness pairs)

.gg.colour.fromBytes

If the colour is input as a 0xrrggbb, convert it to an integer

Parameter(s):

Name Type Description
c byte[] | int colour 0xrrggbb

Returns:

Name Type Description
int int representation of colour

.gg.colour.qualify

Turn a colour or a word into a colour

Parameter(s):

Name Type Description
c byte | byte[] | char[] | symbol

Returns:

Name Type Description
byte[] 0xrrggbb

.gg.colour.setAlpha

Set alpha on a list of fills

Parameter(s):

Name Type Description
alpha byte | int
fill int[]

Returns:

Name Type Description
int[] New ARGB colours