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:


  1. Create a scatterplot with legend
  2. Create scientifically formatted axis labels
  3. Create multipanel plots
  4. 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.

R logo

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.

Video - STAT 485 Lesson: 15.1

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.

Video - STAT 485 Lesson: 15.2

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.

Video - STAT 485 Lesson: 15.3

15.4 Introducing layout() for Multi-Panel Plots

Here we’ll introduce the function layout() for creating multipanel plot layouts.

Video - STAT 485 Lesson: 15.4

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.

Video - STAT 485 Lesson: 15.5

15.6 Creating a Finished Multi-Panel Plot - Part I

Now we’ll put everything together to create a publication-quality multi-panel plot.

Video - STAT 485 Lesson: 15.6

15.7 Creating a Finished Multi-Panel Plot - Part II

This is a continuation of the last video on creating a multi-panel plot.

Video - STAT 485 Lesson: 15.7

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.

Video - STAT 485 Lesson: 15.8

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.

Video - STAT 485 Lesson: 15.9