Legend control
📖 Scenario: You are creating a simple scatter plot to compare two groups of data points. You want to add a legend to clearly show which color represents which group.
🎯 Goal: Build a scatter plot with two groups of points and add a legend that correctly labels each group.
📋 What You'll Learn
Create two numeric vectors called
group1 and group2 with the exact values specified.Create a vector called
labels with the exact group names.Plot the points for both groups with different colors.
Add a legend that uses the
labels vector and matches the colors used in the plot.💡 Why This Matters
🌍 Real World
Legends help people understand what different colors or symbols mean in charts, like showing sales by region or comparing groups in a study.
💼 Career
Data analysts and scientists often create plots with legends to communicate insights clearly to others.
Progress0 / 4 steps