# Python Bar Plot – Visualize Categorical Data in Python 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:

## 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
sn.barplot(x="season",y="cnt",data=BIKE)
plt.show()
```

Output: