Bar chart represent
categorical data using rectangular bars. Each bar in a bar chart represents a
category, and the height or length of the bar represents the value associated
with that category.
For example, as you see below plot, it clearly project how many people like the fruits Apple, Banana, Orange, Grapes.
In the above example.
a. there are four categories (Apple, Banana, Orange, and Grapes) with corresponding values.
b. The height of the bars on the chart reflect the values category Apple has a value of 120, category Banana has a value of 45, and so on.
hello_world.py
import matplotlib.pyplot as plt
fruits = ['Apple', 'Banana', 'Orange', 'Grapes']
liked_by_count = [120, 45, 32, 87]
plt.bar(fruits, liked_by_count)
plt.xlabel('Fruits')
plt.ylabel('Liked by people')
plt.title('Bar Chart Example')
plt.show()
No comments:
Post a Comment