From the course: Data Visualization in R with ggplot2
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Annotating your visualization
From the course: Data Visualization in R with ggplot2
Annotating your visualization
- [Instructor] It's sometimes helpful to add annotations to our visualizations to help display some additional context. These annotations may come in the form of adding text, lines, or more complex objects to our visualizations. We'll discuss three functions that you can use to annotate your visualizations. First, the annotate() function in ggplot allows us to add simple annotations. These can be any shape or text element. The geom_hline() function adds horizontal lines and the geom_vline() function adds vertical lines. Let's give these functions a try in our studio. I'm going to change things up a little bit this time and switch from the bar graph that we've been working with to a scatter plot that we created earlier in the course. I have the code loaded here to create that scatter plot, so I'm going to go ahead and run that. And as you can see, this scatter plot shows how an institution's average SAT score varies with tuition. When I look at this chart, I notice that there's a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.