lollipop

A value drawn as a stem from the baseline with a dot at its end.

Only withxyxyzplane
Four lollipop stems at 0, 1, 2 and 3, the middle two three times as tall as the outer two.Four lollipop stems at 0, 1, 2 and 3, the middle two three times as tall as the outer two.

#Values at positions

lollipop(x: 0, 1, 2, 3; y: 0.125, 0.375, 0.375, 0.125) draws a stem from the baseline to each value, with a dot at its end, the two series paired by position as a scatter's are. A stem occupies only the value it stands at, which is the shape of a quantity that belongs to a single value — a probability mass P(X = k) — where a bar would draw an interval around k.

The stems stand on an axis ruled in names, and run along the other: lollipop(x: 0.42, 0.31, 0.19; y: North, South, East) runs them out along x. With both axes numeric, orientation decides: vertical (the default) or horizontal. Both axes in names are refused (canvas/lollipop-axes). In space a stem stands on the floor at each (x, y) and rises to its z; all three are required there.

#Tallying readings

One coordinate alone is the readings, and the mark counts them: lollipop(x: #rolls.face) stands a stem at every distinct value, as tall as the number of times it occurs. Nothing is binned. The counts run along the other axis, which must be numeric:

graph{
    lollipop(x: #rolls.face)
}(
    y format: few, many
)

[canvas/lollipop-axes]'lollipop(x: …)' counts its readings and stands the counts up the y axis, which is ruled in names — a count is a number

#Lollipops side by side

Where two or more lollipop marks have a stem at the same position, the stems stand side by side there in source order, so two distributions are read stem against stem. A position only one of them has keeps its stem where it is.

graph{
    lollipop(x: 0, 1, 2, 3, 4; y: 0.240, 0.412, 0.265, 0.076, 0.008; colour: blue; label: $\mathrm{Bin}(4, 0.3)$)
    lollipop(x: 0, 1, 2, 3, 4; y: 0.301, 0.361, 0.217, 0.087, 0.026; colour: orange; label: $\mathrm{Poisson}(1.2)$)
}

#Error bars

error draws a capped bar through each dot along its stem, written as a scatter's is: a half-width per stem, or the interval's two ends. It needs both x and y — a tallied stem is a count of readings, with no row of its own to carry one.

graph{
    lollipop(x: #rates.month; y: #rates.rate; error: #rates.lo .. #rates.hi)
}

#Attributes

On any plane
xImplicitAnimatable
Where the stems stand: numbers, names, or a dataset column (#rolls.face). Paired with y by position; a pair either axis cannot read is dropped whole. Written alone it is the readings instead, and the mark counts them.
Can be written as shorthand: lollipop:value
yAnimatable
The values the stems reach, paired with x by position — or, written alone, the readings to be counted, with the counts running out along x.
orientation
Which way the stems run when nothing else says: 'vertical' up from the x axis, 'horizontal' out from the y axis. A categorical axis says it first, and in the readings form the readings' own axis does, so this is read only when two numeric axes leave the question open.
verticalhorizontal
Defaultvertical
colour
The colour of each stem and its dot: one colour, a list cycled stem by stem, or an expression read as a bar's, from a column or #self.value — colour: #self.value -> (..<0: red; 0..: blue).
colour-style
Also written: color
Defaultblue
size
The dot at the stem's end, in the same units a scatter's markers take: one size, a list stem by stem, or an expression giving one per stem, size: #self.value -> 0..100 -> 4 + 8_.
size-style
Default6
width
The stem's thickness, as a line's: one width, a list stem by stem, or an expression giving one per stem — width: #self.value -> 0..100 -> 1 + 5_.
width-style
Default2
opacity
How solid each stem and its dot are, 0 to 1: one opacity, a list stem by stem, or an expression giving one per stem.
opacity-style
Default1
style
How each stem is drawn: solid, dashed or dotted. One style, a list stem by stem, or an expression giving one per stem, as colour: takes.
stroke-style-style
Defaultsolid
show-labelsAnimatable
When true, writes each stem's value beside its dot — clear of it, above for vertical stems and beyond the dot for horizontal ones. Animatable, so a step can fade the numbers in over a picture the reader has already read.
Also written: labels
Defaultfalse
label
Text drawn beside the element — rich text, so $maths$ and inline formatting render. Fades and draws with the element.
hiddenAnimatable
Declared but not drawn. Animatable — hidden: true !cue.to{false}(at: 2) reveals it — and unlike a cue, a hidden element still frames the plot, so the axes do not jump when it appears.
Defaultfalse
lock
Keeps the reader from editing this element on an editable: graph. Nothing at all on a graph that is not editable.
Also written: locked
Defaultfalse
text-sizeAnimatable
Text size.
Default20
layerAnimatable
Paint order among the marks: a higher layer is drawn later, on top; equal or omitted, the marks stack in document order (later on top). Written z: before the argand plane took that letter for its coordinate.
group
The groups this lollipop belongs to, comma-separated: group: Treated, Projected. It is drawn in the colour of the first group that has one, over its own colour:, and the footer's key names every group. A stroke the graph's key: gives a group does not change it.
Only withxyplane
errorAnimatable
Each stem's uncertainty, a capped bar through its dot along the stem: a half-width per stem, or the interval's two ends — error: #trials.lo .. #trials.hi — as a scatter's error: takes. Only where both x: and y: are written; a tallied stem is a count, with no row to carry one.
Only withxyzplane
zAnimatable
In space, the height of each stem over its (x, y) on the floor, paired by position with x and y.

#Derived attributes

Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.

valueDerived
Each stem's value, one per stem, which a style attribute follows as #self.value: size: #self.value -> 0..1 -> 4 + 8_.
totalDerived
The sum of the heights its stems reach, in the value axis's units — the number of readings where it tallies one coordinate; a dash with no stems.
maxDerived
The tallest stem's height, in the value axis's units; a dash with no stems.
minDerived
The shortest stem's height, in the value axis's units; a dash with no stems.
countDerived
The number of stems this mark draws — the number of distinct values where it tallies readings — counting its own only, whatever stands beside them; 0 with none.

#Allowed in

#Examples

A lollipop for each face of a die, as tall as the number of times it was rolled.A lollipop for each face of a die, as tall as the number of times it was rolled.
graph{
    lollipop(x: #rolls.face)
}
Three horizontal lollipops for North, South and East, each labelled with its value.Three horizontal lollipops for North, South and East, each labelled with its value.
graph{
    lollipop(
        x: 0.42, 0.31, 0.19
        y: North, South, East
        show-labels
    )
}
A blue binomial and an orange Poisson mass function from 0 to 8, each pair of stems standing side by side at its value, the two closest at 2 and 3.A blue binomial and an orange Poisson mass function from 0 to 8, each pair of stems standing side by side at its value, the two closest at 2 and 3.
graph{
    lollipop(
        x: 0, 1, 2, 3, 4, 5, 6, 7, 8
        y: 0.028, 0.121, 0.233, 0.267, 0.200, 0.103, 0.037, 0.009, 0.001
        colour: blue
        label: $\mathrm{Bin}(10, 0.3)$
    )
    lollipop(
        x: 0, 1, 2, 3, 4, 5, 6, 7, 8
        y: 0.050, 0.149, 0.224, 0.224, 0.168, 0.101, 0.050, 0.022, 0.008
        colour: orange
        label: $\mathrm{Poisson}(3)$
    )
}(
    x domain: [-1, 9]
    y domain: [0, 0.3]
)
In space: the joint probability mass function of two dice-like variables, a stem standing on each pair (x, y) as tall as its probability.In space: the joint probability mass function of two dice-like variables, a stem standing on each pair (x, y) as tall as its probability.
graph:xyz{
    lollipop(x: 1, 1, 1, 2, 2, 2, 3, 3, 3; y: 1, 2, 3, 1, 2, 3, 1, 2, 3; z: 0.05, 0.10, 0.05, 0.10, 0.30, 0.10, 0.05, 0.10, 0.15)
}(
    z axis label: probability
)

Last updated