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 often in my analysis and reports because they are intuitive. Most people would probably agree that bar charts are the most intuitive since we learned them early in elementary school.

However, I use them less when working on complex analysis.

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

Even so, your manager may not always appreciate simple graphs, so it’s important to understand their preferences.

It’s surprising how many people feel undervalued 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 *