MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Histograms, Bins & Probability Density0%
Study MaterialsCheatsheet
Data Visualization & Applied StatisticsProgress 0%
1.1Why Data Visualization Matters in Decision Making1.2Python Visualization Landscape: Matplotlib vs Seaborn vs Plotly1.3Setting Up Jupyter, Inline Plotting & Figure Sizing
2.1Matplotlib Anatomy: Figure, Axes, Subplots & Ticks2.2Line Plots, Markers, Line Styles & Multiple Series2.3Bar Charts, Horizontal Bars & Stacked Bars2.4Histograms, Bins & Probability Density
HomeTutorialsData Visualization & Applied StatisticsHistograms, Bins & Probability Density
Seaborn Themes, Palettes & Aesthetics

Histograms, Bins & Probability Density

Intermediate6 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

1. What is a Histogram?

A Histogram visualizes the distribution of a continuous numerical variable by dividing the data range into equal-width intervals called bins and counting how many data observations fall into each bin.

Difference from Bar Chart: A bar chart compares discrete categories (like Cities). A histogram illustrates the spread, skewness, and frequency density of a continuous numeric variable (like Employee Ages or Salaries).

2. Plotting Histograms with Custom Bins & KDE

1import matplotlib.pyplot as plt
2import numpy as np
3 
4# Generate 1,000 synthetic transaction amounts
5np.random.seed(42)
6transaction_amounts = np.random.gamma(shape=3, scale=500, size=1000)
7 
8fig, ax = plt.subplots(figsize=(8, 5))
9# bins=30 creates 30 bins; density=True normalizes counts to probability density
10n, bins, patches = ax.hist(
11 transaction_amounts,
12 bins=30,
13 color='#3b82f6',
14 edgecolor='#1e293b',
15 alpha=0.75
16)
17 
18ax.set_title('Transaction Value Frequency Distribution')
19ax.set_xlabel('Transaction Amount (INR)')
20ax.set_ylabel('Frequency (Transaction Count)')
21ax.axvline(np.median(transaction_amounts), color='red', linestyle='--', label=f'Median: ₹{np.median(transaction_amounts):.0f}')
22ax.legend()
23 
24plt.show()

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What is the key distinction between a bar chart and a histogram?
Question 2
What happens to a histogram if you choose too few bins (e.g. bins=2)?
Question 3
What does setting density=True in ax.hist() accomplish?
Question 4
Which parameter in ax.hist() adds a visible border between neighboring bars to improve visual clarity?
Question 5
What does ax.axvline(x=500) draw on a plot?

Next Lesson

Seaborn Themes, Palettes & Aesthetics

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Bar Charts, Horizontal Bars & Stacked BarsSeaborn Themes, Palettes & Aesthetics

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

12-Month Data Analysis Mastery Program

Master Full-Stack Data Analytics (Excel, SQL, Python, Power BI & Tableau)

Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext