dermestid / bold-phylodiv-scripts

Scripts to calculate phylodiversity and its distribution from BOLD DNA barcode data.
1 stars 0 forks source link

Change plot limits function to exclude extreme outliers #123

Closed dermestid closed 3 years ago

dermestid commented 3 years ago

Makes the plot easier to read if the scale isn't determined by a single value which is several times bigger than all the others.

Example code in make_plot.js:

    const limits = (s, acc) => {
        const min_val = min(s, acc);
        const max_val = d3.max(s, acc);
        if (s.length <= 2) return [min_val, round(max_val)];
        let without_max = [...s];
        without_max.splice(d3.greatestIndex(s, acc), 1);
        const second_biggest = d3.max(without_max, acc);
        const max = (second_biggest * 1.5 < max_val) ? second_biggest : max_val;
        return [min_val, round(max)];
    };