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.4679

np.percentile(x,75,interpolation='higher')

1412.2137

Does anyone know if matplotlib can set which type of interpolation to use
when it's calculating the percentiles?

Thanks for your help!

···

--
Matthew Bradley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190122/523e7293/attachment.html>

Matplotlib's boxplot function has two steps:

1) pass the data to cbook.boxplots_stats
2) pass the stats to Axes.bxp

We 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-py

I 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#L417

Pass that list of dictionaries to Axes.bxp:

   - https://github.com/Geosyntec/wqio/blob/master/wqio/features.py#L496
   - https://github.com/Geosyntec/wqio/blob/master/wqio/viz.py#L261

···

On Tue, Jan 22, 2019 at 12:13 PM Matthew Bradley <mbatr27 at gmail.com> 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.4679

np.percentile(x,75,interpolation='higher')
>>>1412.2137

Does 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
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190122/5e0947cc/attachment.html>

This is great, thanks!

···

On Tue, Jan 22, 2019 at 5:20 PM Paul Hobson <pmhobson at gmail.com> wrote:

Matplotlib's boxplot function has two steps:

1) pass the data to cbook.boxplots_stats
2) pass the stats to Axes.bxp

We 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-py

I 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#L417

Pass that list of dictionaries to Axes.bxp:

   - https://github.com/Geosyntec/wqio/blob/master/wqio/features.py#L496
   - https://github.com/Geosyntec/wqio/blob/master/wqio/viz.py#L261

On Tue, Jan 22, 2019 at 12:13 PM Matthew Bradley <mbatr27 at gmail.com> > 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.4679

np.percentile(x,75,interpolation='higher')
>>>1412.2137

Does 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
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Matthew Bradley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190122/fce4f74a/attachment-0001.html>