Matplotlib Bars

Horizontal Bar Chart

import matplotlib.pyplot as plt

# Data to plot
categories = ['A', 'B', 'C', 'D']
values = [3, 7, 5, 2]

# Create a horizontal bar chart
plt.barh(categories, values, color='green', edgecolor='black')

# Add titles and labels
plt.title('Horizontal Bar Chart')
plt.xlabel('Values')
plt.ylabel('Categories')

# Display the plot
plt.show()