# Boxplot quartiles Classic List Threaded 3 messages Reply | Threaded
Open this post in threaded view
|

## Boxplot quartiles

 Hi all,I have the following array:x = np.array([1920.5508, 513.4158, 1071.6049, 1412.2137, 1378.3534, 561.4679])when I put it into a boxplot it shows a boxplot with values that I would get from np.percentile:np.percentile(x,[0,25,50,75,100],interpolation='linear')>>>array([ 513.4158 , 689.00215 , 1224.97915 , 1403.748625, 1920.5508 ])I would like for the 1st and 3rd quartile to be calculated with a different interpolation and then display these different values in the boxplot, i.e.np.percentile(x,25,interpolation='lower')>>>561.4679np.percentile(x,75,interpolation='higher')>>>1412.2137Does anyone know if matplotlib can set which type of interpolation to use when it's calculating the percentiles?Thanks for your help!-- Matthew Bradley _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

## Re: Boxplot quartiles

 Matplotlib's boxplot function has two steps:1) pass the data to cbook.boxplots_stats2) pass the stats to Axes.bxpWe did it this way so that people could skip step one and use their own stats with Axes.bxp.Axes.bxp expects a list of dictionaries with the following keys: `'label', 'mean', 'iqr', 'cilo', 'cihi', 'whishi', 'whislo', 'fliers', 'q1', 'med', 'q3'` E.g, cilo & cihi are optional if you're not drawing the notch.We documented it here:https://matplotlib.org/gallery/statistics/bxp.html#sphx-glr-gallery-statistics-bxp-pyI use this feature myself in a library I wrote for work:Compute custom boxplot stats: https://github.com/Geosyntec/wqio/blob/master/wqio/features.py#L417Pass that list of dictionaries to Axes.bxp: On Tue, Jan 22, 2019 at 12:13 PM Matthew Bradley <[hidden email]> wrote:Hi all,I have the following array:x = np.array([1920.5508, 513.4158, 1071.6049, 1412.2137, 1378.3534, 561.4679])when I put it into a boxplot it shows a boxplot with values that I would get from np.percentile:np.percentile(x,[0,25,50,75,100],interpolation='linear')>>>array([ 513.4158 , 689.00215 , 1224.97915 , 1403.748625, 1920.5508 ])I would like for the 1st and 3rd quartile to be calculated with a different interpolation and then display these different values in the boxplot, i.e.np.percentile(x,25,interpolation='lower')>>>561.4679np.percentile(x,75,interpolation='higher')>>>1412.2137Does anyone know if matplotlib can set which type of interpolation to use when it's calculating the percentiles?Thanks for your help!-- Matthew Bradley _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

## Re: Boxplot quartiles

 This is great, thanks! On Tue, Jan 22, 2019 at 5:20 PM Paul Hobson <[hidden email]> wrote:Matplotlib's boxplot function has two steps:1) pass the data to cbook.boxplots_stats2) pass the stats to Axes.bxpWe did it this way so that people could skip step one and use their own stats with Axes.bxp.Axes.bxp expects a list of dictionaries with the following keys: `'label', 'mean', 'iqr', 'cilo', 'cihi', 'whishi', 'whislo', 'fliers', 'q1', 'med', 'q3'` E.g, cilo & cihi are optional if you're not drawing the notch.We documented it here:https://matplotlib.org/gallery/statistics/bxp.html#sphx-glr-gallery-statistics-bxp-pyI use this feature myself in a library I wrote for work:Compute custom boxplot stats: https://github.com/Geosyntec/wqio/blob/master/wqio/features.py#L417Pass that list of dictionaries to Axes.bxp: On Tue, Jan 22, 2019 at 12:13 PM Matthew Bradley <[hidden email]> wrote:Hi all,I have the following array:x = np.array([1920.5508, 513.4158, 1071.6049, 1412.2137, 1378.3534, 561.4679])when I put it into a boxplot it shows a boxplot with values that I would get from np.percentile:np.percentile(x,[0,25,50,75,100],interpolation='linear')>>>array([ 513.4158 , 689.00215 , 1224.97915 , 1403.748625, 1920.5508 ])I would like for the 1st and 3rd quartile to be calculated with a different interpolation and then display these different values in the boxplot, i.e.np.percentile(x,25,interpolation='lower')>>>561.4679np.percentile(x,75,interpolation='higher')>>>1412.2137Does anyone know if matplotlib can set which type of interpolation to use when it's calculating the percentiles?Thanks for your help!-- Matthew Bradley _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users -- Matthew Bradley _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users