Change language

Understanding the different Box Plot with visualization

Loading Libraries

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

Data preparation

spread = np.random.rand ( 50 ) * 100

center = np.ones ( 25 ) * 50

flier_high = np.random.rand ( 10 ) * 100 + 100

flier_low = np.random.rand ( 10 ) * - 100

data = np.concatenate ((spread, center, flier_high, flier_low), 0 )

  

print (data)

Output:

 [35.94741387 98.49500418 37.2487085 93.19618571 6.34263359 49.10532713 53.86860981 58.59362227 36.96325746 62.27757508 65.44118887 73.79592156 95.15399991 79.94114982 16.64273792 88.35737021 14.84581489 91.61486239 16.03299406 73.12589808 0.76759854 8.63636833 33.25606049 46.05712779 81.60993207 43.94169286 95.0390852 2.96961334 8.79716665 38.21446718 12.15763603 61.18542821 70.93695599 48.90136391 54.6233727 77.27315695 14.63597135 68.22763576 52.23548596 14.34491407 55.53669512 93.63144771 15.66242535 72.47360029 67.82493039 0.34568417 0.46750944 63.39884046 70.39370656 83.42420235 50. 50. 50 . 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 134.61039367 133.42423423 132.77938791 157.75858139 105.99552891 159.1713425 190.9938417 118.33354777 142.13310114 113.5 4291724 -32.73427425 -34.92884623 -49.28116565 -15.24891626 -14.57460618 -9.48256045 -46.74250253 -36.3992666 -88.14980994 -64.49187441] 

Code # 1: Normal section of the box

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data)

 
plt.show ()

Output:

Code # 2: notch area

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data, 1 )

 
plt.show ()

Output:

Code # 3: Box Graph showing emissions

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data, 0 , ’gD’ )

  
plt.show ()

Output:

Code # 4: No Emissions Plot Box

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data, 0 , ’’)

 
plt.show ()

Output:

Code # 5: Horizontal rectangle-method/">rectangle

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data, 0 , ’rs’ , 0 )

  
plt.show ()

Exit :

Code No. 6: Horizontal rectangle-method/">rectangle with a change in the length of the whiskers

plt.figure (figsize = ( 7 , 5 ))

plt.boxplot (data, 0 , ’rs’ , 0 , 0.75 )

 
plt.show ()

Output:

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically