plotly/box-plot-ink
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| plotly | info, and warning with style = "strict". A rule of the house style |
none, edit by hand | All versions |
A box plot of one variable draws outlines that a five-number summary does not need. If only the summary matters, draw Tufte's quartile plot with a few lines and dots.
What the rule reports
Section titled “What the rule reports”The rule reports px.box and go.Box with exactly one of x or y, when the call writes no point
settings, notches, means, quartile method, precomputed statistics, box style or orientation, and
has no ** argument. A px call with color, a facet or an animation is left alone. The rule
does not prove that a box plot is wrong, and the advice holds only when the five numbers are
all the reader needs.
For example, the rule reports this box plot.
fig = go.Figure(go.Box(y=values))When only the minimum, quartiles, median and maximum are needed, draw this instead.
low, q1, median, q3, high = 1, 2.5, 4, 5.5, 7fig = go.Figure(go.Scatter( x=[0, 0, None, 0.03, 0.03, None, 0.03, 0.03, None, 0, 0, None], y=[low, q1, None, q1, median - 0.05, None, median + 0.05, q3, None, q3, high, None], mode="lines",))The five numbers above are an example, computed from the values 1 to 7 with linear quartiles. Compute the five numbers for each distribution, and choose the offset and the gap at the median for the scale of the data. Keep the box when its outliers, notches, hover information or statistical convention are needed. The whiskers of a default box end at the last values within 1.5 times the interquartile range of the box, and the two ends need not be the minimum and the maximum. A drawing from the minimum to the maximum therefore shows another statistic.
The book prefers the quartile plot with the middle half offset (page 124), and says that the choice also rests on statistical and aesthetic criteria. The table gives what plotly 7.1.0 drew for four groups. The numbers measure the drawing and do not show that the two forms are equal as statistics, so the rule has no fix.
| Drawing of four groups | Straight segments | Filled box area in square pixels |
|---|---|---|
four default go.Box traces |
36 | 15,241.7 |
| a thinner box | 28, and the median was hidden | not recorded |
the offset quartile plot in go.Scatter |
16 | 0 |
Questions of the presentation review
Section titled “Questions of the presentation review”The rule reports in code what these questions of the presentation guides (xpd charts, xpd tables, and xpd views) ask of the drawn display.
| Question | Page | Principle | What it asks |
|---|---|---|---|
| quartile-plot | 124 | The quartile plot | Would an offset quartile plot, a line with a gap for the middle half, show the five numbers with less ink than the box? |
Diagnostic message
Section titled “Diagnostic message”Tufte's quartile plot reduces box outlines when only a five-number summary is needed. If that suits this figure, compute the minimum, quartiles, median and maximum and draw an offset middle half with a median gap using go.Scatter with mode='lines'. Default box whiskers end at sample values within the 1.5 IQR fences, which can differ from the minimum and maximum, so retain the box when its outlier, notch or hover information matters. Choose on statistical and aesthetic grounds. No automatic fix is offered.See all rules in the plotly pack.