15 Visualizing Data I - Enhancing Scatter Plots
Overview
In this chapter we’ll begin a somewhat more detailed examination of the graphical capabilities in R, and here we’ll focus on scatterplots.
Objectives
Upon completion of this lesson, you should be able to:
- Create a scatterplot with legend
- Create scientifically formatted axis labels
- Create multipanel plots
- Create plots with a secondary y-axis
Data and R Code Files
The R code file and data files for this lesson can be found on the Essential R - Notes on learning R page.
15.1 Basic Use of plot()
We’ve already used plot()
, but without much discussion of what it can do. Here we’ll look a bit more at (some of) the features of plot()
. Note that there is a lot happening in the background when we call plot()
- a coordinates system is set up, default axis labels generated, and range limits for the axes are selected.
15.2 Introducing lines()
and Formatting Axis Labels
We can add any arbitrary line segements to a plot using lines()
, as we’ll demonstrate here. We’ll also look at how we can control the format of axis labels.
15.3 Putting Together a Publication-Quality Scatter Plot
Now we’ll put together what we’ve done so far to create a polished plot.
15.4 Introducing layout()
for Multi-Panel Plots
Here we’ll introduce the function layout()
for creating multipanel plot layouts.
15.5 Controlling Plot Dimensions - quartz()
and X11()
When you are working on plots, you may want to control the size of the plotting window. This can be done using X11()
or quartz()
to open a new graphical device whose size you can control.
15.6 Creating a Finished Multi-Panel Plot - Part I
Now we’ll put everything together to create a publication-quality multi-panel plot.
15.7 Creating a Finished Multi-Panel Plot - Part II
This is a continuation of the last video on creating a multi-panel plot.
15.8 Using Loops for Multi-Panel Figures
Here we’ll consider if and when it would make sense to use a loop to create a multi-panel plot.
15.9 Adding a Secondary y-axis
We’ll wind up this chapter with a demonstration of how to add a secondary y-axis to a plot.