课程: Data Visualization in R with ggplot2
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Cleaning up legends
- [Instructor] Some scales produce visualizations with meanings that aren't obvious to the viewer. Legends can help us clarify these visualizations. A legend provides the viewer with a key to interpreting the scale. On this bar graph, the meaning of the X and y values are obvious from their context. The X axis shows region and the Y axis shows the number of institutions. However, color isn't meaningful by itself. But if we add a legend that explains the colors, we immediately grasp their purpose. The guide_legend function allows us to display legends for scales that don't have intuitive meanings. We commonly use legends for scale, such as fill, color, and shape. Let's give it a try in Rstudio. Here's the code to produce our bar graph of schools. And when I ran this code, R automatically understood that a legend was necessary to explain color, so it added one. It uses some default information. The variable that I mapped to fill was called control so that becomes the title of the legend…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。