📦 Box Plot

Last Updated: 06 Nov 2025


Box plot is used to show data distribution, spread, and outliers. It displays:

  • Minimum
  • Q1 (25%)
  • Median
  • Q3 (75%)
  • Maximum
  • Outliers

Hinglish Tip 🗣: Box plot se pata chalta hai data kitna spread hai aur outliers kaha hain.


Basic Box Plot

import matplotlib.pyplot as plt
import numpy as np

data = np.random.randn(100)

plt.boxplot(data)
plt.show()

Useful Parameters for Box Plot

  • vert - Vertical or horizontal box plot
  • patch_artist - Fill box with color
  • boxprops - Box properties
  • whiskerprops - Whisker properties
  • capprops - Cap properties
  • flierprops - Flier properties
  • medianprops - Median properties
  • notch - Show notch
  • showmeans - Show means
import matplotlib.pyplot as plt
import numpy as np

data = np.random.randn(200)

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

plt.boxplot(
    data,
    patch_artist=True,
    boxprops=dict(facecolor="#a5d8ff", color="#1c7ed6", linewidth=1.5),
    medianprops=dict(color="#d00000", linewidth=2),
    whiskerprops=dict(color="#1c7ed6", linewidth=1.5),
    capprops=dict(color="#1c7ed6", linewidth=1.5),
    flierprops=dict(marker="o", markerfacecolor="#ff6b6b", markersize=7, alpha=0.7)
)

plt.title("Box Plot")
plt.grid(axis="y", linestyle="--", alpha=0.4)
plt.show()

Note : We will Cover more box plot in future