liveBook · Manning

Bar chart

As explained in Starting Data Analytics with Generative AI and Python

A bar chart, or bar plot, represents values for discrete categories using rectangular bars whose lengths or heights encode magnitude.

A bar chart represents discrete categories with rectangular bars whose lengths or heights encode magnitude. It turns a business question—such as which product categories sell most in each Brazilian region—into a visual comparison that can guide stock management, staffing, or promotions. section 3.3 section 3.3.1

A practical bar-chart workflow includes:

  • Use grouped bars and distinct colors to compare categories across regions, while checking that labels and columns match the intended DataFrame. section 3.3.1 section 3.3.2

Comparing regional revenue

A grouped bar chart can place Brazilian states on the x-axis, revenue on the y-axis, and product categories in separate colored bars. Inspect the resulting DataFrame and chart rather than trusting generated code: an undefined column caused a plotting error, and a deprecated parameter produced a warning.

import seaborn as sns
import matplotlib.pyplot as plt

plt.figure(figsize=(12, 8))
sns.barplot(data=sales_by_region, x='customer_state', y='revenue', 
hue='product_category_name_english', ci=None)
plt.title('Revenue by Product Category and Region')
plt.show()

plt.figure(figsize=(12, 8))
sns.barplot(data=sales_by_region, x='customer_state', y='sales_volume',
hue='product_category_name_english', ci=None)
plt.title('Sales Volume by Product Category and Region')
plt.show()

Review the concrete Seaborn and Matplotlib workflow for plotting revenue and sales volume by category and region. section 3.3.1

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Explains grouped comparisons and plotting workflow, but stops short of chart internals or formal statistical interpretation.
Examples
Uses grouped category-by-region plots for Brazilian sales volume, revenue, average product price, freight value, and payment value.
What it assumes
Assumes merged DataFrames and grouped measures, while introducing descriptive statistics and visualizations as analytical tools.
What you can do after
Apply it via Seaborn and Matplotlib to compare grouped business measures and inspect generated results for errors.
How it connects
Connects descriptive statistics, descriptive analytics, heatmaps, scatter plots, predictive analytics, and prescriptive analytics.

Also explained in

Compare how 9 books explain bar chart →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.