Box Plot Statistics with Python Matplotlib

A box plot summarizes the distribution of a dataset using 5 key statistics: Minimum, Q1, Median, Q3, and Maximum. The box spans the Interquartile Range (IQR = Q3 − Q1), capturing the middle 50% of data. In Python (Matplotlib) python import matplotlib.pyplot as plt import numpy as np data = np.random.normal(50, 15, 200) fig, ax = plt.subplots() bp = ax.boxplot(data, patch_artist=True, medianprops=dict(color='red', linewidth=2), boxprops=dict(facecolor='wheat'), whiskerprops=dict(color='black'), capprops=dict(color='green', linewidth=2)) ax.set_title("Box Plot Example") plt.show() medianprops → controls the red median line boxprops → fills the IQR box (beige/wheat) capprops → styles the min/max caps (green) whiskerprops → controls the whisker lines #DataAnalysis #Python #Matplotlib #PowerBI #DataVisualization #DataScience #Analytics

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories