💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

BOX PLOT from aggregated values

All the BOX PLOT examples from https:// plot.ly/python/box-plots/ seems to be plotting with raw data. Any way for me to draw box plots with aggregated values instead?

I.e., instead of letting the box plots (slowly) calculate the mean, median, std-dev etc values from millions of records I have, can I calculate myself then pass the calculated mean, median, min/max, std-dev etc to box plots and have it just plot the results intead?

Thanks

I was looking for the same thing but had no luck. I even looked through the code did not find and hooks or options to allow this. I ended up making a code change in Plotly.js to support what I needed. It’s a little bit of a hack but it is a stable change that follows most of the existing plotly coding conventions.

You can see the diff here in my forked branch: https://github.com/lepricon49/plotly.js/commit/ed64f141077d3acab1ccd7a534d327aaf460ba0f

To use this, just add a “calcdataOverride” property to each boxplot object in your data array that needs overridden values. You still have to pass in at least one value for the box plot to think it has work to do but that shouldn’t have any impact on performance. I pass in my aggregate values to allow plotly to calculate some of the values so I only need to override the q1 and q2 properties. Look at the calculateStats function in Plotly.js to see the properties that can be overridden.

I hope this helps.

2 Likes

Yes, indeed. That helps quite a lot. I’m not a Python or JavaScript developer, your code definitely helps a lot. Thank you very much.