0

Some researchers often report results in form of 5 number summary. While for my methodology I have raw data, I would like to compare box plots.

Hence, is it possible to draw boxplot from 5 number summary using matplotlib/seaborn?

The idea has already been discussed for R [here] and here2.

petezurich
  • 9,280
  • 9
  • 43
  • 57
Martan
  • 565
  • 5
  • 17

1 Answers1

1

A 5 number summary could be seen as a dataset of 5 numbers: [min, Q1, Q2, Q3, max]. Therefore, you can generate a dataset with these 5 numbers and plot them in a boxplot.

For example:

import seaborn

def fiveNumBox(mi, q1, q2, q3, ma):
    data = [mi, q1, q2, q3, ma]
    ax = seaborn.boxplot(data=data, orient="h")
    ax.get_figure().savefig('figure.png')

fiveNumBox(1, 2, 3, 4, 5)

Generates: enter image description here

H. Ross
  • 470
  • 3
  • 17