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
Bar Charts, Horizontal Bars & Stacked Bars0%
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 StatisticsBar Charts, Horizontal Bars & Stacked Bars
Histograms, Bins & Probability Density

Bar Charts, Horizontal Bars & Stacked Bars

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

1. Comparing Discrete Categories

While line charts represent continuous trends, Bar Charts are designed to compare discrete categories (e.g., Sales by Department, Revenue by Region, Traffic by Channel).


2. Vertical vs Horizontal Bar Charts

  • Vertical Bars (ax.bar): Best when categories are few (3 to 7) and have short names.
  • Horizontal Bars (ax.barh): Best when comparing many categories (8+) or when category labels are long (e.g., "Customer Relationship Management Department").
1import matplotlib.pyplot as plt
2 
3cities = ['Mumbai', 'Delhi', 'Bengaluru', 'Hyderabad', 'Chennai']
4sales = [1420, 1380, 1150, 890, 780]
5 
6fig, ax = plt.subplots(figsize=(9, 4.5))
7# Horizontal bar chart sorted by value
8ax.barh(cities, sales, color='#0284c7', height=0.6)
9 
10ax.set_title('Top Indian Metro Markets by Revenue (Cr INR)')
11ax.set_xlabel('Revenue (in Crores)')
12ax.invert_yaxis() # Puts the highest value at the top!
13 
14# Add direct data value labels on bars
15for idx, val in enumerate(sales):
16 ax.text(val + 20, idx, f"₹{val} Cr", va='center', fontweight='bold', fontsize=10)
17 
18plt.show()

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
Which Matplotlib method renders a horizontal bar chart?
Question 2
Why are horizontal bar charts strongly recommended when category labels are lengthy?
Question 3
What does calling ax.invert_yaxis() do on a horizontal bar chart?
Question 4
How do you construct a stacked bar chart in Matplotlib?
Question 5
What is the recommended best practice for ordering categories in a comparison bar chart?

Next Lesson

Histograms, Bins & Probability Density

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

Related Lessons

Previous LessonNext Lesson
Line Plots, Markers, Line Styles & Multiple SeriesHistograms, Bins & Probability Density

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