Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
No results
  • About AskPython
  • Blog
  • Contact Me
  • Free Online Developer Tools Hub
  • Home
  • Meet the Team
  • Privacy Policy
  • Python
  • Python Course for Beginners Online FREE
  • Python Tutorial – Mega Index
  • Terms and Conditions

🚀 Supercharge your YouTube channel's growth with AI.

Try YTGrowAI Free
  • Home
  • Blog
  • About AskPython
  • Python Course
  • Start Here

Python Bar Plot – Visualize Categorical Data in Python

  • Safa MulaniSafa Mulani
  • September 28, 2020
  • Matplotlib, Python Programming
Python Bar Plot – Visualize Categorical Data in Python

Hey, readers. In this article, we will be focusing on creating a Python bar plot.

Data visualization enables us to understand the data and helps us analyze the distribution of data in a pictorial manner.

BarPlot enables us to visualize the distribution of categorical data variables. They represent the distribution of discrete values. Thus, it represents the comparison of categorical values.

The x axis represents the discrete values while the y axis represents the numeric values of comparison and vice versa.

Let us now focus on the construction of Bar plots in the upcoming section.


Creating a Python Bar Plot Using Matplotlib

Python matplotlib module provides us with various functions to plot the data and understand the distribution of the data values.

The matplotlib.pyplot.bar() function is used to create a Bar plot using matplotlib module.

Syntax:

matplotlib.pyplot.bar(x, height, width, bottom, align)
  • x: The scalar x-coordinates of the barplot
  • height: The height of the bars to be plotted
  • bottom: The vertical baseline
  • width: The width of the bars to be plotted(optional)
  • align: The type of alignment of the bar plot(optional).

Further, we need to make sure and understand that only categorical data values can be provided to the barplot.

Let us now try to implement a barplot using the matplotlib module.

Example:

import matplotlib.pyplot as plt
country = ['INDIA', 'JAPAN', 'CHINA', 'USA', 'GERMANY']
population = [1000,800,600,400,1100]
plt.bar(country,population)
plt.show()

Output:

BARPLOT Using Matplotlib
BARPLOT Using Matplotlib

Bar Plot using Seaborn module

Python Seaborn module is built over the Matplotlib module and offers us with some advanced functionalities to have a better visualization of the data values.

Syntax:

seaborn.barplot(x,y)

Example:

import seaborn as sn
import matplotlib.pyplot as plt
import pandas as pd
BIKE = pd.read_csv("BIKE.csv")
sn.barplot(x="season",y="cnt",data=BIKE)
plt.show()

Output:

BARPLOT Using Seaborn
BARPLOT Using Seaborn

Conclusion

Thus, in this article, we have understood the various techniques to construct a Python bar plot .

Feel free to comment below, in case you come across any question.

For more such posts related to Python, Stay tuned and till then, Happy Learning!!


References

  • Bar Plot with Python matplotlib module — Documentation
  • Bar Plot with Seaborn module — Documentation
Safa Mulani
Safa Mulani

An enthusiast in every forthcoming wonders!

Articles: 189
Flask User Authentication – How to Setup User Login in Flask?
Previous Post Flask User Authentication - How to Setup User Login in Flask?
Next Post Deploy Flask App on VPS
Deploy Flask App on VPS

Related Posts

What Does %s Mean in Python String Formatting?

What Does %s Mean in a Python Format String?

  • November 30, 2026
Python Convert String to List

Python Convert String to List: Choose the Right Method

  • November 29, 2026
Translate String Python

Translate String Python

  • November 29, 2026

Partner Websites

  • GoLangDocs
  • LinuxForDevices
  • CodeForGeek

Popular Categories

  • Python Programming
  • Python Modules
  • OOPS in Python
  • Python Programming Examples
  • Strings in Python

Hall of Fame

  • Python Programming
  • OOPS in Python
  • Creating Python Modules
  • Args and Kwargs in Python
  • Python Dictionary (Dict) Tutorial
  • Python List – 15 Things You MUST Know
  • Python Set – Things You MUST Know
  • Python String Functions: Methods by Task

Important Links

  • Home
  • Python Course
  • Start Here
  • Blog
  • About AskPython
Latest posts
  • np.linalg.eig: Eigenvalues and Eigenvectors
  • What Does %s Mean in a Python Format String?
  • How to Use np.sin() in NumPy
  • cv2.imread: Load Images with OpenCV
  • pd.read_json: Read JSON Into a DataFrame

Copyright © 2026 - AskPython. All rights reserved.