datavisyn/chartjs-chart-box-and-violin-plot

Quantiles Methods not working

Rovel opened this issue · 6 comments

Rovel commented

Hi,

I'm trying to apply different quantile methods to match a report made in another lib used by Re-Dash but it seem as I change the quantiles the graph value does not change.
Example Code:
https://codepen.io/Rovel/pen/RwwdzbG

Reference Issue:
getredash/redash#4428

  1. you have to change the quantiles method in the "xAxes" since you have a horizontal box plot
  2. even if you change it to e.g. fivenum in my test the results don't change even with the different method.
Rovel commented

@sgratzl yes I tried this too, xAxes and try actually all available quantiles methods and nothing changes, not sure if is a thing in the horizontal Box, but with numpy and other command line libs the value change, so I must infer that is something in the horizontal box and quantiles methods in this lib, can you confirm that the quantiles methods are working in the horizontal box plot?
Thanks

can you give a dataset in which you can see different results and also the code (e.g python,...) how to compute the various formats? The different methods that are currently implemented show an effect especially on dataset with an even number of elements since they essentially have different methods to combine two values for q1, q3, median, ...

Rovel commented

Hi,

See if this is is enought info, 11 numbers, evaluationg only q3 but from here we can test the others too...

Here follows a dataset and a example running with python 3.8.1 with the numpy lib:

>>> import numpy as np
>>> x = [3.375, 3.75, 3.875, 3, 3, 3.5, 3.125, 3, 2.625, 3.375, 3]
>>> np.percentile(x, 75, interpolation='linear')
3.4375
>>> np.percentile(x, 75, interpolation='higher')
3.5
>>> np.percentile(x, 75, interpolation='lower')
3.375
>>> np.percentile(x, 75, interpolation='nearest')
3.5
>>> np.percentile(x, 75, interpolation='midpoint')
3.4375

I see, there seem to be numerous versions how to compute the value in case you have to interpolate it.

So far this library implements two methods taken from R

The latter was added to be the same as when using the R boxplot function.

However, I can take a look to also implement the other methods. A PR is also welcome

Rovel commented

sure I will try to help with a PR or something, but since JS is not my strong suit it will probably need a good review 😃