Bar charts are used to plot and compare between different values of data. It can be plotted by using bar() function of the matplotlib module.

The syntax for plotting a bar graph in Python is:*align='center'data=None**kwargs)

A simple example of a bar chart in Python is given below.

import numpy as np
import matplotlib.pyplot as plt

languages = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
y_pos = np.arange(len(languages))
popularity = [10, 8, 6, 4, 2, 1]

# Plot the bar chart, popularity, align='center')

# Setting the title and labels
plt.title('Programming language statistics')
plt.xticks(y_pos, languages)

# Display the plot
Bar chart in Python

In Conclusion

Bar graphs are popularly used for data visualization in Python. You may like this tutorial on other kinds of plots in Python: Data Visualization in Python (With Tutorials).


Please enter your comment!
Please enter your name here