Diverging Bar Charts
📖 Scenario: You are working as a data analyst for a company that wants to visualize customer satisfaction survey results. The survey asked customers to rate their satisfaction on a scale from -5 (very dissatisfied) to +5 (very satisfied). You want to create a diverging bar chart to clearly show positive and negative feedback.
🎯 Goal: Build a diverging bar chart using matplotlib that displays customer satisfaction scores for different product features. Positive scores should extend to the right, negative scores to the left, with bars colored differently based on satisfaction.
📋 What You'll Learn
Create a dictionary called
features with exact keys and integer values for satisfaction scores.Create a list called
colors that assigns 'green' for positive scores and 'red' for negative scores.Use a
for loop with variables feature and score to plot horizontal bars with correct colors and positions.Print the matplotlib figure with the diverging bar chart showing feature names on the y-axis.
💡 Why This Matters
🌍 Real World
Diverging bar charts are useful to show positive and negative feedback clearly, such as customer satisfaction, survey results, or sentiment analysis.
💼 Career
Data analysts and scientists often use diverging bar charts to communicate insights from data that has both positive and negative values, making it easier for stakeholders to understand.
Progress0 / 4 steps