Recall & Review
beginner
What is the purpose of a legend in an R plot?
A legend explains the symbols, colors, or line types used in a plot so the viewer can understand what each element represents.
Click to reveal answer
beginner
How do you add a basic legend to a plot in R?
Use the
legend() function, specifying the position, labels, and symbols or colors to match the plot elements.Click to reveal answer
beginner
What argument in
legend() controls the position of the legend?The
x argument controls the position. It can be a keyword like "topright", "bottomleft", or coordinates like c(1,2).Click to reveal answer
intermediate
How can you change the colors of legend symbols in R?
Use the
col argument inside legend() to specify colors matching the plot symbols or lines.Click to reveal answer
intermediate
What does the
pch argument do in the legend() function?It sets the plotting character (symbol) used in the legend to match the points or symbols shown in the plot.
Click to reveal answer
Which function is used to add a legend to a plot in R?
✗ Incorrect
The
legend() function adds a legend to an existing plot.How do you position a legend at the top right corner of a plot?
✗ Incorrect
Using
x = "topright" places the legend at the top right corner.Which argument controls the colors of symbols in the legend?
✗ Incorrect
The
col argument sets the colors of the legend symbols or lines.If you want the legend symbols to match the plot points, which argument do you set?
✗ Incorrect
The
pch argument sets the plotting character (symbol) in the legend.Can you specify exact coordinates for the legend position in R?
✗ Incorrect
You can specify exact coordinates like
c(x, y) to position the legend precisely.Explain how to add and customize a legend in a basic R plot.
Think about what you want the legend to show and where it should appear.
You got /5 concepts.
Describe the role of the 'pch' and 'col' arguments in the legend() function.
These arguments help the legend look like the plot points or lines.
You got /4 concepts.