Geometries
Each geometry below acts as a single layer within a GG visualization. The layers can
be composed using .qp.stack
or .qp.split
to create custom visualizations.
The geomtries that are available are provided in the grid below, with further detail and examples of each following.
Examples
Each of the examples below can be rendered in the IDE by prepending .qp.go[width; height]
to the front of the plot description, or can be rendered to a PNG file using
.qp.png[`:filename.png; width; height]
in front. For example, use the following for
a 500 pixel by 500 pixel scatter chart:
t: ([]x: til 45);
.qp.go[500; 500] .qp.point[t; `x; `y; ::]
.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
`decorations
- Disable line and point decorations
Parameters:
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:
Type | Description |
---|---|
table | specification table for a line chart |
Example: Load data and basic plot
t : ([]x: til 100; y: { sin[3*x] + sin[2*x] } acos[-1] * til[100] % 100);
.qp.area[t; `x; `y; ::]
Example: Disable points and outline
.qp.area[t; `x; `y]
.qp.s.geom[enlist[`decorations]!enlist 0b]
Example: Filled and alpha
.qp.area[t; `x; `y]
.qp.s.geom[`alpha`areaAlpha`fill!(0x7f; 0x2f; 0xb22222)]
Example: Grouped and stacked
t : raze { ([]
x: til 100;
y: 5 + { sin[rand[5]*x] + sin[rand[5]*x] } acos[-1] * til[100] % 100; z: x)
} each `a`b`c;
.qp.area[t; `x; `y]
.qp.s.aes[`fill`group; `z`z]
, .qp.s.scale[`fill; .gg.scale.colour.cat10]
, .qp.s.geom[``position!(::; `stack)]
Example: Grouped and stacked with properties
.qp.area[t; `x; `y]
.qp.s.aes[`fill`group; `z`z]
, .qp.s.scale[`fill; .gg.scale.colour.cat `blues]
, .qp.s.geom[`colour`position`alpha`strokewidth!(`black; `stack; 0x7f; 3)]
.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`sortByValue
- Sort bars by y axis value (largest to smallest)
Parameters:
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:
Type | Description |
---|---|
table | specification tree for a bar chart |
See Also: .gg.scale.limits
Example: Load data and basic plot
t: ([] x: 15#.Q.a; y: 10 + sums 15?-2 -1 1 2);
.qp.bar[t; `x; `y; ::]
Example: Change colour and order by value
.qp.bar[t; `x; `y]
.qp.s.geom[``fill`sortByValue!(::; 0x0070cd; 1b)]
Example: Annotate with text labels and start at 0
.qp.stack (
.qp.bar[t; `x; `y]
.qp.s.geom[``fill`sortByValue!(::; 0x0070cd; 0b)];
.qp.text[t; `x; `y; `y]
.qp.s.geom[``offsety`align`bold`size!(::;-10;`middle;1b;11)])
Example: Grouped
t: raze { ([] cat:x; x: 15#.Q.a; y: 10 + sums 15?-2 -1 1 2)} each `cat1`cat2`cat3`cat4;
.qp.bar[t; `x; `y]
.qp.s.aes[`fill; `cat]
Example: Grouped and stacked
.qp.bar[t; `x; `y]
.qp.s.aes[`fill`group; `cat`cat]
, .qp.s.geom[``position!(::; `stack)]
, .qp.s.scale[`fill; .gg.scale.colour.cat `reds]
Example: Grouped and dodged with custom y and fill scales
.qp.bar[select from t where x in "abcde"; `x; `y]
.qp.s.aes [`fill`group; `cat`cat]
, .qp.s.geom [``position`gap!(::; `dodge;0.05)]
, .qp.s.scale [`fill; .gg.scale.colour.cat `rdbu]
// start y axis at 0
, .qp.s.scale [`y; .gg.scale.limits[0 0N] .gg.scale.linear]
Example: Draw a ribbon through the median and deviation of each category
.qp.stack (
.qp.bar[select from t where x in "abcde"; `x; `y]
.qp.s.aes [`fill`group; `cat`cat]
, .qp.s.geom [``position`gap!(::; `dodge;0.05)]
, .qp.s.scale [`fill; .gg.scale.colour.cat `rdbu]
// start y axis at 0
, .qp.s.scale [`y; .gg.scale.limits[0 0N] .gg.scale.linear];
.qp.ribbon[select med y, dev y by x from t where x in "abcde"; `x; `y; `y1]
.qp.s.geom[``alpha!(::;0x3f)])
.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.
Parameters:
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:
Type | Description |
---|---|
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; ::]
Example: Basic numeric plot
.qp.boxplot[t; `z; `y; ::]
.qp.empty
Return an empty plot. Can be used as a spacer.
Returns:
Type | Description |
---|---|
table | specification tree for an empty plot (spacer) |
Example: Empty plot
.qp.empty[]
.qp.errorbar
Vertical error bar geometry.
- X - position along the horizontal
- Y - first point of the interval
- YEND - second point of the interval
Series can be dodged (see examples below).
Aesthetic mappings (.qp.s.aes
, dynamic) supported:
`fill
- Fill colour`alpha
- Opacity`group
- Grouping (combined with`position
geom settings)
Geometry settings (.qp.s.geom
, static) supported:
`fill
- Fill colour`alpha
- Opacity`position
-`dodge
Parameters:
Name | Type | Description |
---|---|---|
table | table | |
x | symbol | column name |
y | symbol | column name |
yend | symbol | column name |
settings | dict | null | settings for the visual (geom/bins/etc) |
Returns:
Type | Description |
---|---|
table | tree specifying an interval chart |
Example: Stacking with a point
t:update l1:x-.25,l2:x+.25 from
0!select max x by y, y2 from
([]x:.st.gen.normal 100;y:100?`a`b`c`d; y2:100?`e`f`g`h);
.qp.stack (
.qp.errorbar[select from t where y2=`e; `y; `l1; `l2; ::];
.qp.point [select from t where y2=`e; `y; `x]
.qp.s.geom[``size!(::;5)])
Example: Dodged error bars stacked with bars
.qp.stack (
.qp.bar[t;`y;`x]
.qp.s.aes[`group`fill; `y2`y2] ,
.qp.s.scale[`fill; .gg.scale.colour.cat `rdylbu] ,
.qp.s.geom[``position!(::;`dodge)];
.qp.errorbar[t;`y;`l1;`l2]
.qp.s.aes[`group; `y2] ,
.qp.s.geom[``position`fill!(::;`dodge;`black)])
.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`sortByValue
- Sort bars by y axis value (largest to smallest)
Parameters:
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:
Type | Description |
---|---|
table | specification tree for a bar chart |
See Also: .gg.scale.limits
Example: Load data and basic plot
t: ([] x: 15#.Q.a; y: 10 + sums 15?-2 -1 1 2);
.qp.hbar[t; `y; `x; ::]
Example: Change colour and order by value
.qp.hbar[t; `y; `x]
.qp.s.geom[``fill`sortByValue!(::; `slategrey; 1b)]
Example: Annotate with text labels and start at 0
.qp.stack (
.qp.hbar[t; `y; `x]
.qp.s.geom[``fill`sortByValue!(::; `slategrey; 0b)];
.qp.text[t; `y; `x; `y]
.qp.s.geom[``offsetx`align`bold`size!(::;10;`middle;1b;11)])
Example: Grouped
t: raze { ([] cat:x; x: 15#.Q.a; y: 10 + sums 15?-2 -1 1 2)} each `cat1`cat2`cat3`cat4;
.qp.hbar[t; `y; `x]
.qp.s.aes[`fill; `cat]
Example: Grouped and stacked
.qp.hbar[t; `y; `x]
.qp.s.aes[`fill`group; `cat`cat]
, .qp.s.geom[``position!(::; `stack)]
, .qp.s.scale[`fill; .gg.scale.colour.cat `puor]
Example: Grouped and dodged with custom y and fill scales
.qp.hbar[select from t where x in "abcde"; `y; `x]
.qp.s.aes [`fill`group; `cat`cat]
, .qp.s.geom [``position`gap!(::; `dodge;0.05)]
, .qp.s.scale [`fill; .gg.scale.colour.cat `brbg]
// start y axis at 0
, .qp.s.scale [`x; .gg.scale.limits[0 0N] .gg.scale.linear]
.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.
Parameters:
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:
Type | Description |
---|---|
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; ::]
Example: Basic numeric plot
.qp.hboxplot[t; `y; `z; ::]
.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
Parameters:
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:
Type | Description |
---|---|
table | specification tree for a heatmap |
Example: Load data and basic heatmap with angled x axis
t : ([]
c1:100000?20?`5;
c2:100000?50?`5;
x:5 * .st.gen.normal 100000;
y:sin .st.gen.normal 100000;
z:.st.gen.normal 100000);
.qp.theme[`axis_tick_label_anchor_x`axis_tick_label_angle_x!(`left; 90)]
.qp.heatmap[t; `c1; `c2; ::]
Example: Continuous * categorical with fill colour
.qp.heatmap[t; `x; `c2]
.qp.s.geom[``fill!(::; 0x0070cd)]
Example: Add a new aggregation over y
and map to fill colour and bin counts
.qp.heatmap[t; `x; `z]
.qp.s.aggr[.st.a.count[] , .st.a.custom[`yout; `y; avg]]
, .qp.s.aes[`fill; `yout]
, .qp.s.aes[`alpha; `]
, .qp.s.scale[`fill; .gg.scale.colour.gradient2[0f; `firebrick; 0xebebeb; `steelblue]]
, .qp.s.binx[`c;50;0]
, .qp.s.biny[`c;50;0]
.qp.herrorbar
Horizontal error bar geometry.
- X - first point of the interval
- XEND - second point of the interval
- YEND - position along the vertical
Series can be dodged (see examples below).
Aesthetic mappings (`.qp.s.aes, dynamic) supported:
`fill
- Fill colour`alpha
- Opacity`group
- Grouping (combined with`position
geom settings)
Geometry settings (.qp.s.geom
, static) supported:
`fill
- Fill colour`alpha
- Opacity`position
-`dodge
Parameters:
Name | Type | Description |
---|---|---|
table | table | |
x | symbol | column name |
xend | symbol | column name |
y | symbol | column name |
settings | dict | null | settings for the visual (geom/bins/etc) |
Returns:
Type | Description |
---|---|
table | tree specifying an interval chart |
Example: Stacking with a point
t:update l1:x-.25,l2:x+.25 from
0!select max x by y, y2 from
([]x:.st.gen.normal 100;y:100?`a`b`c`d; y2:100?`e`f`g`h);
.qp.stack (
.qp.herrorbar[select from t where y2=`e; `l1; `l2; `y; ::];
.qp.point [select from t where y2=`e; `x; `y]
.qp.s.geom[``size!(::;5)])
Example: Dodged error bars stacked with bars
.qp.stack (
.qp.hbar[t;`x;`y]
.qp.s.aes[`group`fill; `y2`y2] ,
.qp.s.scale[`fill; .gg.scale.colour.cat `rdylbu] ,
.qp.s.geom[``position!(::;`dodge)];
.qp.herrorbar[t;`l1;`l2;`y]
.qp.s.aes[`group; `y2] ,
.qp.s.geom[``position`fill!(::;`dodge;`black)])
.qp.hhistogram
Horizontal histogram chart - the length of each bar depicts the observations of a distinct value.
- X - position along the vertical.
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
`sortByValue
- Sort bars by y axis value (largest to smallest)
Parameters:
Name | Type | Description |
---|---|---|
table | table | data to be visualized |
x | symbol | column name |
settings | dict | null | settings for the visual (geom/bins/etc) |
Returns:
Type | Description |
---|---|
table | specification tree |
Example: Load data and continuous hhistogram
t: raze {[category; num]
([]
c1: category;
x: 2 * (-2 + rand 4f) + .st.gen.normal num;
y: .st.gen.normal num;
z: {acos[-1] * x % max x} .st.gen.normal num)
}'[`a`b`c`d`e; 10000+5?35000];
.qp.hhistogram[t; `c1; ::]
Example: Change the scale to start at 0 and order by value
.qp.hhistogram[t; `c1]
.qp.s.scale[`x; .gg.scale.limits[0 0N] .gg.scale.linear] ,
.qp.s.geom[``sortByValue!(::;1b)]
Example: Continuous axis with fill colour
.qp.hhistogram[t; `x]
.qp.s.geom[``fill!(::; 0x0070cd)]
Example: Dodge based on another column
.qp.hhistogram[t; `x]
.qp.s.scale[`x; .gg.scale.limits[0 0N] .gg.scale.linear]
// Requires a 2D bin transform rather than a 1D
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[`position`gap!(`dodge; 0)]
, .qp.s.aes[`group; `c1]
, .qp.s.aes[`fill; `c1]
Example: Add an explicit fill scale
.qp.hhistogram[t; `x]
.qp.s.scale[`x; .gg.scale.limits[0 0N] .gg.scale.linear]
// Requires a 2D bin transform rather than a 1D
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[``position!(::; `dodge)]
, .qp.s.aes[`group; `c1]
, .qp.s.aes[`fill; `c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `pubugn]
Example: Change from a stack to a dodge with a blue scale
.qp.hhistogram[t; `x]
.qp.s.scale[`x; .gg.scale.limits[0 0N] .gg.scale.linear]
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[``position!(::; `stack)] // <- changed to stack
, .qp.s.aes[`group; `c1]
, .qp.s.aes[`fill; `c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `pubugn]
Example: Stack with an binned line of another continuous column using 100 bins
.qp.stack (
.qp.hhistogram[t; `x]
.qp.s.scale[`x; .gg.scale.limits[0 0N] .gg.scale.linear]
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; (`c;100;0); ::; .st.a.count[]; ::] ]
, .qp.s.biny[`x;100;0]
, .qp.s.geom[``position`gap!(::;`stack;0)]
, .qp.s.aes[`group; `c1]
, .qp.s.aes[`fill; `c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `bugn];
.qp.path[t; `count__; `y]
.qp.s.stat[ .gg.stat.bin1d[`y; (`c;100;0); .st.a.count[]; ::] ]
, .qp.s.geom[``fill`size!(::; 0xcd0000;1.5)])
.qp.hinterval
Horizontal interval chart - an interval between two numbers on the X axis for each value along the Y axis.
- X - first point of the interval
- XEND - second point of the interval
- Y - position along the vertical
Series can be dodged (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
-`dodge
`gap
- Gap between bars as percent of width/height (i.e.,0.03
for 3%)`align
- Bar alignment
Parameters:
Name | Type | Description |
---|---|---|
table | table | data to be visualized |
x | symbol | column name |
xend | symbol | column name |
y | symbol | column name |
settings | dict | settings for the visual (geom/bins/etc) |
Returns:
Type | Description |
---|---|
table | tree specifying an hinterval chart |
Example: Load data and basic plot
t: ([] x: `a`b`c`d`e`f`g; y1: -50+7?100; y2: 50+7?100);
.qp.hinterval[t; `y1; `y2;`x; ::]
Example: Filled
.qp.hinterval[t; `y1; `y2; `x]
.qp.s.geom[``fill!(::;0x0070cd)]
Example: Grouped and dodged
t: raze {[category;num] ([]
c1: category;
c2: num?`cat1`cat2`cat3;
x: (-2 + rand 4f) + .st.gen.normal num;
y: .st.gen.normal num)
}'[`a`b`c`d`e; 10000+5?35000];
t: select y1: min x, y2: max x by c1, c2 from t;
.qp.hinterval[t; `y1; `y2; `c1]
.qp.s.aes[`fill; `c2]
, .qp.s.scale[`fill; .gg.scale.colour.cat10]
, .qp.s.aes[`group;`c2]
, .qp.s.geom[``position!(::; `dodge)]
Example: Positive/negative bar charts
t: ([]y:0; y2: (.st.gen.normal[30] % 5) + sin 3 * acos[-1] * til[30] % 30; x:til 30);
t: update pos:y2>=0 from t;
.qp.hinterval[t; `y; `y2; `x]
.qp.s.aes[`fill; `pos]
, .qp.s.scale[`fill; .gg.scale.colour.cat 01b!(0xcd4000; 0x0070cd)]
Example: Stack a moving average line
.qp.stack (
.qp.hinterval[t; `y; `y2; `x]
.qp.s.aes[`fill; `pos]
, .qp.s.scale[`fill; .gg.scale.colour.cat 01b!(0xcd4000; 0x0070cd)]
, .qp.s.geom[``alpha!(::;0x7f)];
.qp.path[update y2: 10 mavg y2 from t; `y2; `x]
.qp.s.geom[``size!(::;2)])
.qp.histogram
Vertical histogram chart - the height of each bar depicts the number of observations of each distinct value
- X - the position along the X axis
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
`sortByValue
- Sort bars by y axis value (largest to smallest)
Parameters:
Name | Type | Description |
---|---|---|
table | table | data to be visualized |
x | symbol | column name |
settings | dict | null | settings for the visual (geom/bins/etc) |
Returns:
Type | Description |
---|---|
table | specification tree |
Example: Load data and continuous histogram
t: raze {[category; num]
([]
c1: category;
x: 2 * (-2 + rand 4f) + .st.gen.normal num;
y: .st.gen.normal num;
z: {acos[-1] * x % max x} .st.gen.normal num)
}'[`a`b`c`d`e; 10000+5?35000];
.qp.histogram[t; `c1; ::]
Example: Change the scale to start at 0 and order by value
.qp.histogram[t; `c1]
.qp.s.scale[`y; .gg.scale.limits[0 0N] .gg.scale.linear] ,
.qp.s.geom[``sortByValue!(::;1b)]
Example: Continuous axis with fill colour
.qp.histogram[t; `x]
.qp.s.geom[``fill!(::; 0x0070cd)]
Example: Dodge based on another column
.qp.histogram[t; `x]
.qp.s.scale[`y; .gg.scale.limits[0 0N] .gg.scale.linear]
// Requires a 2D bin transform rather than a 1D
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[`position`gap!(`dodge; 0)]
, .qp.s.aes[`group`fill; `c1`c1]
Example: Add an explicit fill scale
.qp.histogram[t; `x]
.qp.s.scale[`y; .gg.scale.limits[0 0N] .gg.scale.linear]
// Requires a 2D bin transform rather than a 1D
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[``position!(::; `dodge)]
, .qp.s.aes[`group`fill; `c1`c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `pubugn]
Example: Change from a stack to a dodge with a blue scale
.qp.histogram[t; `x]
.qp.s.scale[`y; .gg.scale.limits[0 0N] .gg.scale.linear]
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; ::; ::; .st.a.count[]; ::] ]
, .qp.s.geom[``position!(::; `stack)] // <- changed to stack
, .qp.s.aes[`group`fill; `c1`c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `pubugn]
Example: Stack with an binned line of another continuous column using 100 bins
.qp.stack (
.qp.histogram[t; `x]
.qp.s.scale[`y; .gg.scale.limits[0 0N] .gg.scale.linear]
, .qp.s.stat[ .gg.stat.bin2d[`x`c1; (`c;100;0); ::; .st.a.count[]; ::] ]
, .qp.s.binx[`c;100;0]
, .qp.s.geom[``position`gap!(::;`stack;0)]
, .qp.s.aes[`group`fill; `c1`c1]
, .qp.s.scale[`fill; .gg.scale.colour.cat `bugn];
.qp.path[t; `y; `count__]
.qp.s.stat[ .gg.stat.bin1d[`y; (`c;100;0); .st.a.count[]; ::] ]
, .qp.s.geom[``fill`size!(::; 0xcd0000;1.5)])