Create a bar plot in Matplotlib

Python

Matplotlib

Bar

Create vertical

Luc B.

Python

Matplotlib

Bar Plot

Bar charts are important tools for creating comparative visualizations of discrete data. Matplotlib makes it easy to create these powerful plots.

Code Example

Use the plt.bar() function to create a bar plot in Matplotlib.

import matplotlib.pyplot as plt

labels = ['Amy', 'Rob', 'Dimitri', 'Sarah', 'Brian']
values = [60, 56, 63, 75, 48]

# Create bar plot here
plt.bar(labels, values)

plt.ylabel('Typing Speed (wpm)')
plt.show()

png

To create a horizontal bar plot, take a look at this article.