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








