Geometries

.qp.area

Area chart - draw a filled line given the X and Y coordinates of the line.

  • X - horizontal position
  • Y - vertical position

Series can be stacked (see examples below).

Aesthetic mappings (.qp.s.aes, dynamic) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `group - Grouping (combined with `position geom settings)

Geometry settings (.qp.s.geom, static) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `position - `stack

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification table for a line chart

Example: Load Data and Basic Plot

      t : ([]x: raze 5#enlist 10?`5; y: 50?5; z: raze 5#'til 10);

      .qp.area[t; `x; `y; ::]

Image

Example: Filled

      .qp.area[t; `x; `y]
          .qp.s.geom[enlist[`fill]!enlist `firebrick]

Image

Example: Filled and Alpha

      .qp.area[t; `x; `y]
          .qp.s.geom[`alpha`fill!(0x7f; 0xb22222)]

Image

Example: Grouped

      .qp.area[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.aes[`group;`z]

Image

Example: Grouped and Stacked

      .qp.area[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[enlist[`position]!enlist `stack]

Image

Example: Grouped and Stacked with Properties

      .qp.area[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[`colour`position`alpha`strokewidth!(`white; `stack; 0x7f; 3)]

Image

.qp.bar

Vertical bar chart.

  • X - places the bar along the x axis
  • Y - maps the height of the bar

Series can be stacked or dodged (see examples below).

By default, the bars will start at the smallest value, unless extended in order to get a nice range for axis ticks. The minimum or maximum can be extended to any desired value. This is useful to set the minimum to 0 to compare the absolute heights rather than the relative heights. This is done by setting the .gg.scale.limits[(min;max)] on the Y scale.

Aesthetic mappings (.qp.s.aes, dynamic) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `group - Grouping (combined with `position geom settings)

Geometry settings (.qp.s.geom, static) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `position - `dodge or `stack
  • `gap - Gap between bars as percent of width/height (i.e., 0.03 for 3%)
  • `align - Bar alignment

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification tree for a bar chart

See Also: .gg.scale.limits

Example: Load Data and Basic Plot

      t : ([]x: raze 5#enlist 10?`5; y: 50?5; z: raze 5#'til 10);

      .qp.bar[t; `x; `y; ::]

Image

Example: Filled

      .qp.bar[t; `x; `y]
          .qp.s.geom[enlist[`fill]!enlist `firebrick]

Image

Example: Filled and Alpha

      .qp.bar[t; `x; `y]
          .qp.s.geom[`alpha`fill!(0x7f; `firebrick)]

Image

Example: Grouped

      .qp.bar[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.aes[`group;`z]

Image

Example: Grouped and Stacked

      .qp.bar[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[enlist[`position]!enlist `stack]

Image

Example: Grouped and Dodged

      .qp.bar[t; `x; `y]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[enlist[`position]!enlist `dodge]

Image

Example: Change width of bars along continuous x axis

     / Since the x axis is continuous, the bars can’t assume that they’ll be 
     /   evenly split, so you’ll need to tell it how many you want (by default 
     /   you just get thin bars unless on integer/categorical axis). The width
     /   is a function of the max and min data, so you need to divide the range
     /   by however many bars you’d like to have

     t:([]l:50?0 1;x:0p+1D*til 50;y:50?100);

     .qp.bar[t;`x;`y] 
           .qp.s.aes[`fill;`l]
         , .qp.s.scale[`fill;.gg.scale.colour.cat10]
              / Size here is the range divided into 50 equal steps, so 50 bars 
              / would fit evenly back to back.
         , .qp.s.geom[``alpha`gap`size!(::;0xff;0;((-).(max;min)@\:t`x)%50)]

Image

.qp.boxplot

Box plot showing median, first and third quartiles, farthest point within 1.5 times the interquartile range from the median on either side, and all outliers (points further than this).

  • X - Category (position along the horizontal)
  • Y - Continuous value (value to summarize)

The X column should be a category, and the Y column continuous.

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification tree for a box plot

Example: Load Data and Basic Categorical Plot

      t : ([]x: raze 50#enlist 10?`5; y: 500?50; z: raze 50#'til 10);

      .qp.boxplot[t; `x; `y; ::]

Image

Example: Basic Numeric Plot

      .qp.boxplot[t; `z; `y; ::]

Image

.qp.empty

Return an empty plot. Can be used as a spacer.

Returns:

Name Type Description
<returns> table specification tree for an empty plot (spacer)

Example: Empty plot

      .qp.empty[]

.qp.hbar

Horizontal bar chart.

  • X - length of the bar
  • Y - vertical position

Series can be stacked or dodged (see examples below).

By default, the bars will start at the smallest value, unless extended in order to get a nice range for axis ticks. The minimum or maximum can be extended to any desired value. This is useful to set the minimum to 0 to compare the absolute heights rather than the relative heights. This is done by setting the .gg.scale.limits[(min;max)] on the X scale.

Aesthetic mappings (.qp.s.aes, dynamic) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `group - Grouping (combined with `position geom settings)

Geometry settings (.qp.s.geom, static) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size
  • `position - `dodge or `stack
  • `gap - Gap between bars as percent of width/height (i.e., 0.03 for 3%)
  • `align - Bar alignment

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification tree for a bar chart

See Also: .gg.scale.limits

Example: Load Data and Basic Plot

      t : ([]x: raze 5#enlist 10?`5; y: 50?5; z: raze 5#'til 10);

      .qp.hbar[t; `y; `x; ::]

Image

Example: Filled

      .qp.hbar[t; `y; `x]
          .qp.s.geom[enlist[`fill]!enlist .gg.colour.FireBrick]

Image

Example: Filled and Alpha

      .qp.hbar[t; `y; `x]
          .qp.s.geom[`alpha`fill!(0x7f; .gg.colour.FireBrick)]

Image

Example: Grouped

      .qp.hbar[t; `y; `x]
          .qp.s.aes[`fill; `z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.aes[`group;`z]

Image

Example: Grouped and Stacked

      .qp.hbar[t; `y; `x]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[enlist[`position]!enlist `stack]

Image

Example: Grouped and Dodged

      .qp.hbar[t; `y; `x]
          .qp.s.aes[`fill; `z]
          , .qp.s.aes[`group;`z]
          , .qp.s.scale[`fill; .gg.scale.colour.cat10]
          , .qp.s.geom[enlist[`position]!enlist `dodge]

Image

Example: Change width of bars along continuous x axis

     / Since the x axis is continuous, the bars can’t assume that they’ll be 
     /   evenly split, so you’ll need to tell it how many you want (by default 
     /   you just get thin bars unless on integer/categorical axis). The width
     /   is a function of the max and min data, so you need to divide the range
     /   by however many bars you’d like to have

     t:([]l:50?0 1;x:0p+1D*til 50;y:50?100);

     .qp.theme[``dynamic_axes!(::;1b)]
         .qp.hbar[t;`y;`x] 
               .qp.s.aes[`fill;`l]
             , .qp.s.scale[`fill;.gg.scale.colour.cat10]
                  / Size here is the range divided into 50 equal steps, so 50 bars 
                  / would fit evenly back to back.
             , .qp.s.geom[``alpha`gap`size!(::;0xff;0;((-).(max;min)@\:t`x)%50)]

Image

.qp.hboxplot

Horizontal box plot showing median, first and third quartiles, farthest point within 1.5 times the interquartile range from the median on either side, and all outliers (points further than this).

  • X - Continuous value (value to summarize)
  • Y - Category (position along the vertical)

The Y column should be a category, and the X column continuous.

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification tree for a box plot

Example: Load Data and Basic Categorical Plot

      t : ([]x: raze 50#enlist 10?`5; y: 500?50; z: raze 50#'til 10);

      .qp.hboxplot[t; `y; `x; ::]

Image

Example: Basic Numeric Plot

      .qp.hboxplot[t; `y; `z; ::]

Image

.qp.heatmap

2D heatmap chart. By default, alpha is mapped to the count of the records in each bucket. This can be changed to map to anything else, or turned of with .qp.s.aes[`alpha; ::] in the settings.

Custom aggregations can be added and mapped as well (see examples below).

Aesthetic mappings (.qp.s.aes, dynamic) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size

Geometry settings (.qp.s.geom, static) supported:

  • `fill - Fill colour
  • `alpha - Opacity
  • `colour - Outline colour
  • `strokewidth - Outline size

Parameter(s):

Name Type Description
table table data to be visualized
x symbol x column
y symbol y column
settings dict | null settings for the visual (theme/geom/etc)

Returns:

Name Type Description
<returns> table specification tree for a heatmap

Example: Load data and basic heatmap

     t : ([]c1:100000?20?`5; c2:100000?50?`5; x:100000?500; y:100000?500; z:100000?500);

     .qp.heatmap[t; `c1; `c2; ::]

Image

Example: Angle the x axis ticks

     .qp.heatmap[t; `c1; `c2]
         .qp.s.theme[`axis_tick_label_anchor_x`axis_tick_label_angle_x!(`left; 90)]

Image

Example: Continuous * Categorical

     .qp.heatmap[t; `x; `c2; ::]

Image

Example: Change fill colour

     .qp.heatmap[t; `x; `c2]
         .qp.s.geom[enlist[`fill]!enlist .gg.colour.SteelBlue]

Image

Example: Add a stroke colour

     .qp.heatmap[t; `x; `c2]
         .qp.s.geom[`colour`fill!(.gg.colour.WhiteSmoke; .gg.colour.SteelBlue)]

Image

Example: Add a new aggregation over z and map to fill colour

     .qp.heatmap[t; `x; `y]
         .qp.s.aggr[.st.a.count[] , .st.a.custom[`zout; `z; avg]]
         , .qp.s.aes[`fill; `zout]
         , .qp.s.aes[`alpha; `]   // <- turn off the default alpha mapping
         , .qp.s.scale[`fill; .gg.scale.colour.gradient[.gg.colour.FireBrick; .gg.colour.SteelBlue]]

Image

Example: Use a 3-valued gradient for fill colour

     .qp.heatmap[t; `x; `y]
         .qp.s.aggr[.st.a.count[] , .st.a.custom[`zout; `z; avg]]
         , .qp.s.aes[`fill; `zout]
         , .qp.s.aes[`alpha; `]
         , .qp.s.scale[`fill; .gg.scale.colour.gradient2[250f; .gg.colour.FireBrick; .gg.colour.White; .gg.colour.Green]]

Image

Example: Change the x and y bin count

     .qp.heatmap[t; `x; `y]
         .qp.s.aggr[.st.a.count[] , .st.a.custom[`zout; `z; avg]]
         , .qp.s.aes[`fill; `zout]
         , .qp.s.aes[`alpha; `]
         , .qp.s.scale[`fill; .gg.scale.colour.gradient[.gg.colour.FireBrick; .gg.colour.SteelBlue]]
         , .qp.s.binx[`c;50;0]
         , .qp.s.biny[`c;30;0]