Skip to content

Commit 7bb93f6

Browse files
committed
[docs] improvements for boxplot
1 parent e1bfd4f commit 7bb93f6

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

src/plot/boxplot.typ

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,49 +128,34 @@
128128
/// )
129129
/// ```
130130
///
131-
/// By default, the mean value is not shown but it can be visualized by setting
132-
/// the @boxplot.mean parameter to a mark or line stroke.
133-
/// ```example
134-
/// #lq.diagram(
135-
/// lq.boxplot((1, 3, 10), mean: "."),
136-
/// lq.boxplot((1, 3, 10), mean: green, x: 2),
137-
/// )
138-
/// ```
139131
///
140132
/// Boxplots can be richly customized as demonstrated below.
141133
/// ```example
134+
/// #let data = (-3, -5, 1, 3, 3, 3, 4, 4, 2, 6, 10, 11)
135+
///
142136
/// #lq.diagram(
143137
/// lq.boxplot(
144-
/// (1, 3, 10),
145-
/// stroke: luma(30%),
146-
/// fill: yellow,
147-
/// median: red
138+
/// data,
139+
/// stroke: luma(30%),
140+
/// fill: yellow,
148141
/// ),
149142
/// lq.boxplot(
150-
/// (1.5, 3, 9),
151-
/// x: 2,
152-
/// whisker: blue,
153-
/// cap: red,
154-
/// cap-length: 0.7,
143+
/// data, x: 2,
144+
/// whisker: blue,
145+
/// cap: red,
146+
/// cap-length: 0.7,
155147
/// median: green
156148
/// ),
157-
/// lq.boxplot(
158-
/// lq.linspace(5.3, 6.2) + (2, 3, 7, 9.5),
159-
/// x: 3,
160-
/// outliers: "x"
161-
/// ),
162-
/// lq.boxplot(
163-
/// lq.linspace(5.3, 6.2) + (2, 3, 7, 9.5),
164-
/// x: 4,
165-
/// outliers: none
166-
/// ),
149+
/// lq.boxplot(data, x: 3, outliers: "x"),
150+
/// lq.boxplot(data, x: 4, outliers: none),
167151
/// )
168152
/// ```
169153
///
170-
/// Some data sets might be too large to be processed in Typst. In this case,
171-
/// the median, the first and third quartil as well as the whiskers can be
172-
/// computed somewhere else and specified manually in Lilaq (see also
173-
/// @boxplot.data).
154+
/// Although Lilaq uses [Komet](https://typst.app/universe/package/komet/) to
155+
/// compute the boxplot, some data sets might be too large to be processed in
156+
/// Typst. In this case, the median, the whiskers, the first and the third
157+
/// quartil can be computed with an external tool and specified manually
158+
/// (see also @boxplot.data).
174159
/// ```example
175160
/// #lq.diagram(
176161
/// width: 4cm,
@@ -228,8 +213,14 @@
228213
/// -> length | color | stroke | gradient | tiling | dictionary
229214
median: 1pt + orange,
230215

231-
/// Whether and how to display the mean value. The mean value can be
232-
/// visualized with a mark (see @plot.mark) or a line like the median.
216+
/// By default, the mean value is not shown but it can be visualized
217+
/// with a mark or a line like the median.
218+
/// ```example
219+
/// #lq.diagram(
220+
/// lq.boxplot((1, 3, 10), mean: "."),
221+
/// lq.boxplot((1, 3, 10), mean: green, x: 2),
222+
/// )
223+
/// ```
233224
/// -> none | lq.mark | str | stroke
234225
mean: none,
235226

@@ -315,7 +306,7 @@
315306
statistics.map(s => s.whisker-low) + statistics.map(s => s.whisker-high) + all-outliers
316307
)
317308
let (xmin, xmax) = minmax(
318-
x.zip(width).map(((xi, w)) => (xi - w, xi + w)).flatten()
309+
x.zip(width).map(((xi, w)) => (xi - calc.max(w, 1)/2, xi + calc.max(w, 1)/2)).flatten()
319310
)
320311

321312
(

0 commit comments

Comments
 (0)