|
128 | 128 | /// ) |
129 | 129 | /// ``` |
130 | 130 | /// |
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 | | -/// ``` |
139 | 131 | /// |
140 | 132 | /// Boxplots can be richly customized as demonstrated below. |
141 | 133 | /// ```example |
| 134 | +/// #let data = (-3, -5, 1, 3, 3, 3, 4, 4, 2, 6, 10, 11) |
| 135 | +/// |
142 | 136 | /// #lq.diagram( |
143 | 137 | /// 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, |
148 | 141 | /// ), |
149 | 142 | /// 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, |
155 | 147 | /// median: green |
156 | 148 | /// ), |
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), |
167 | 151 | /// ) |
168 | 152 | /// ``` |
169 | 153 | /// |
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). |
174 | 159 | /// ```example |
175 | 160 | /// #lq.diagram( |
176 | 161 | /// width: 4cm, |
|
228 | 213 | /// -> length | color | stroke | gradient | tiling | dictionary |
229 | 214 | median: 1pt + orange, |
230 | 215 |
|
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 | + /// ``` |
233 | 224 | /// -> none | lq.mark | str | stroke |
234 | 225 | mean: none, |
235 | 226 |
|
|
315 | 306 | statistics.map(s => s.whisker-low) + statistics.map(s => s.whisker-high) + all-outliers |
316 | 307 | ) |
317 | 308 | 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() |
319 | 310 | ) |
320 | 311 |
|
321 | 312 | ( |
|
0 commit comments