Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 35 of 60 · python

Advanced Plotting: Histograms, Boxplots, and Violin Plots

Duration: 20 minutes

Advanced Plot Types

These plots are essential for summarizing distributions.

Histogram (frequency distribution)

data = np.random.randn(1000)
plt.hist(data, bins=30, edgecolor='black', alpha=0.7)
plt.title('Histogram of Normal Distribution')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.show()

Boxplot (quartiles and outliers)

# Compare two groups
group1 = np.random.normal(0, 1, 200)
group2 = np.random.normal(1, 1.5, 200)
plt.boxplot([group1, group2], labels=['G1', 'G2'], notch=True)
plt.title('Boxplot Comparison')
plt.ylabel('Value')
plt.show()

Violin plot (kernel density + boxplot)

import seaborn as sns
sns.violinplot(data=[group1, group2], palette='muted')
plt.title('Violin Plot')
plt.show()

KDE (kernel density estimate)

sns.kdeplot(data, shade=True, color='green')
plt.title('KDE Plot')
plt.show()

When to use which?

  • Histogram: quick view of frequency; easy to interpret.
  • Boxplot: median, quartiles, outliers.
  • Violin: detailed distribution shape.

Info

Combine a violin and a boxplot for richer insight (sns.violinplot(..., inner='box')).

Previous: Subplots, Grids, and LayoutsNext: Seaborn Overview: Statistical Data Visualization