A bar chart (Documentation) is a graph that represents data using bars. It is useful for visually comparing quantities or frequencies.

Each bar corresponds to a data value within a category, and its height or length indicates the size of that value.

Bar charts can be horizontal or vertical, depending on how the data is best represented.

Key Topics

  1. Compare
    • Clearly compare different items.
    • Useful for analyzing revenue across companies, sales of different products, and other comparisons.
  2. Identify Trends
    • Show changes in data over time.
    • Easily visualize growth rates, declines, and other patterns at a glance.
  3. Organize Data
    • Categorize and structure data clearly.
    • Helps in organizing information by category for better analysis.

Bar charts are intuitive and easy to interpret, making them widely used in business reports, academic research, and everyday data analysis.

Bar chart Code

import matplotlib.pyplot as plt

categories = ['A', 'B', 'C', 'D', 'E']
values = [5, 7, 3, 8, 6]
colors = ['red', 'blue', 'green', 'purple', 'orange']

plt.bar(categories, values, color=colors)

plt.title('Basic Bar Chart with Colors')
plt.xlabel('Categories')
plt.ylabel('Values')

plt.show()
#Horizontal Bar
import matplotlib.pyplot as plt

categories = ['A', 'B', 'C', 'D', 'E']
values = [5, 7, 3, 8, 6]

plt.barh(categories, values)

plt.title('Horizontal Bar Chart')
plt.xlabel('Values')
plt.ylabel('Categories')

plt.show()
# Multiple Bar
import matplotlib.pyplot as plt
import numpy as np

categories = ['A', 'B', 'C', 'D', 'E']
values1 = [5, 7, 3, 8, 6]
values2 = [4, 6, 2, 7, 5]

bar_width = 0.35
index = np.arange(len(categories))

plt.bar(index, values1, bar_width, label='Series 1', color='blue')
plt.bar(index + bar_width, values2, bar_width, label='Series 2', color='green')

plt.title('Multiple Bar Chart')
plt.xlabel('Categories')
plt.ylabel('Values')
plt.xticks(index + bar_width / 2, categories)

plt.legend()

plt.show()
#Stacked Bar
import matplotlib.pyplot as plt

categories = ['A', 'B', 'C', 'D', 'E']
values1 = [5, 7, 3, 8, 6]
values2 = [4, 6, 2, 7, 5]

plt.bar(categories, values1, label='Series 1', color='blue')
plt.bar(categories, values2, bottom=values1, label='Series 2', color='green')

plt.title('Stacked Bar Chart')
plt.xlabel('Categories')
plt.ylabel('Values')

plt.legend()

plt.show()

I use bar charts frequently in my analysis and reports because they are intuitive. Most people would likely agree that bar charts are the most intuitive since they were one of the first types of graphs we learned in elementary school.

However, I tend to use them less when dealing with complex analysis.

That said, I believe at least 80% of problems can be explained with a simple chart like this. While some people prefer complexity, I personally like to keep things simple and straightforward.

That being said, your manager may not always appreciate simple graphs, so make sure to understand their preferences.

It’s surprising how many people think others don’t value their work just because their visualizations look too simple and easy to interpret.

By Mark

-_-

Leave a Reply

Your email address will not be published. Required fields are marked *