This example shows how to control legends in R using ggplot2. First, we load the library. Then, we create a plot object mapping weight and mileage, coloring points by cylinder count. Adding geom_point adds the data points. Using labs(color='Cylinders') sets the legend title. Finally, print(p) renders the plot with the legend visible. The legend appears automatically because ggplot2 creates legends for mapped aesthetics. The legend title is customized with labs(). Without print(), the plot won't display in some environments. This step-by-step trace helps understand how legend control works in R plotting.