plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
17.02k stars 1.86k forks source link

boxplots with q1/median/q3 signature always show fences as min/max on hover #6212

Open hafen opened 2 years ago

hafen commented 2 years ago

Like many who requested the boxplot with q1/median/q3 signature, I have a situation where I am pre-computing these statistics (along with lower and upper fence) from a very large database and then feeding these values to plotly.

I am also pre-computing outliers and adding those as a separate trace.

When using the boxplot with q1/median/q3 signature, we do not have the flexibility to label the fences correctly in the case of outliers.

See the example below (codepen):

image

Here there are no low outliers, so the lower fence is correctly labeled as "min" in the hover. However, the upper fence is labeled as "max" even though there are outliers.

This is confusing to users who wonder why something is labeled as the max when there are points outside of the fence. If I chose not to add the outliers trace, which is probably what most people do who are using this boxplot signature, it would be even more misleading because there would be no hint about whether the underlying data these fences were computed from really have min and max values at the fences, which could lead to some incorrect and bad conclusions about the data.

Fences are not necessarily the min and max, and when using the q1/median/q3 signature, the boxplot has no way of knowing which is the case.

This could be addressed with any of the following:

  1. Allow the ability to override the hover text for this signature
  2. Add an outliers argument to this signature as some have proposed here
  3. Add min/max to the signature – these wouldn't be plotted, but if min < lowerfence, then the hover text for lowerfence would be "lowerfence" (otherwise "min") and similar logic for upperfence/max
  4. Always make the hover text for the lower and upper fences as "lowerfence" and "upperfence" regardless of whether they represent the min/max
  5. Remove the boxplot with q1/median/q3 signature option because it produces a plot that currently by default has statistically incorrect hover info

Personally I lean toward (3).

cthanh2310 commented 1 year ago

do you know the way to hide id when hovering?

LittleLama commented 7 months ago

I agree with #3