Giter Site home page Giter Site logo

Comments (2)

sgratzl avatar sgratzl commented on May 18, 2024

Actually in the latest version:

export function whiskers(boxplot, arr) {
const iqr = boxplot.q3 - boxplot.q1;
// since top left is max
let whiskerMin = Math.max(boxplot.min, boxplot.q1 - iqr);
let whiskerMax = Math.min(boxplot.max, boxplot.q3 + iqr);
if (Array.isArray(arr)) {
// compute the closest real element
for (let i = 0; i < arr.length; i++) {
const v = arr[i];
if (v >= whiskerMin) {
whiskerMin = v;
break;
}
}
for (let i = arr.length - 1; i >= 0; i--) {
const v = arr[i];
if (v <= whiskerMax) {
whiskerMax = v;
break;
}
}
}
return {
whiskerMin,
whiskerMax
};
}

given an array of sorted values arr the lower whisker is computed as the value of the first element in the sorted array that is bigger than Q1 - IQR * 1.5. The upper whisker is the value of the last element that is smaller than Q3 + IQR * 1.5 accordingly. Thus, the lower whisker is at least the minimal value of the array if Q1 - IQR * 1.5 < min since the minimal value represents the first element in the array. I think this implementation is pretty standard similar how R is computing boxplots.

However, if you wanna customize it you have the option to provide the already computed boxplots statistics to the plugin instead of the plain array. See https://github.com/datavisyn/chartjs-chart-box-and-violin-plot#data-structure.

from chartjs-chart-box-and-violin-plot.

gkemp94 avatar gkemp94 commented on May 18, 2024

After looking more at the data structure link, I understand now that I can pass in whiskerMax & whiskerMin to the boxplot and that works. Thanks for pointing me in the correct direction.

from chartjs-chart-box-and-violin-plot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.