Categorical scatter with jitter
📖 Scenario: You work in a small bakery and want to analyze how many cookies of different types are sold each day. You have the sales data for three types of cookies over a week.
🎯 Goal: Create a scatter plot that shows the number of cookies sold for each cookie type. Add jitter to the x-axis positions so the points don't overlap and are easier to see.
📋 What You'll Learn
Create a dictionary called
cookie_sales with keys 'Chocolate', 'Vanilla', and 'Strawberry' and values as lists of daily sales numbers.Create a variable called
jitter_strength to control the amount of jitter on the x-axis.Use a
for loop with variables cookie and sales to iterate over cookie_sales.items().Inside the loop, create a list
x_positions with jittered x-axis values for each sale.Plot the scatter points using
plt.scatter(x_positions, sales).Print the plot with
plt.show().💡 Why This Matters
🌍 Real World
Jittered scatter plots help visualize overlapping data points in categories, useful in sales, biology, and social sciences.
💼 Career
Data analysts and scientists often use jitter plots to explore and present categorical data distributions clearly.
Progress0 / 4 steps