## Chapter 1. Base Graphics in R – One Step at a Time

The goal of this chapter is to give you a comprehensive introduction to base graphics in R. By base graphics, I mean graphics created in R without the use of any additional software or contributed packages. In other words, for the time being, we are using only the default packages in R. After reading this chapter, you should be able to create some nice graphs. Therefore, in this chapter I will introduce you to the basic syntax and techniques used to create and save scatterplots and line plots, though many of the techniques here will be useful for other kinds of graph. We will begin with some basic graphs and then work our way to more complex graphs that include several lines and have axes and axis labels of your choice.

In this chapter, we will cover the following topics:

Basic graphics methods and syntax

Creating scatterplots and line plots

Creating special axes

Adding text—legends, titles, and axis labels

Adding lines—interpolation lines, regression lines, and curves

Graphing several variables, multiple plots, and multiple axes

Saving your graphs as PDF, PostScript, JPG files, and so on

Including mathematical expressions in your graphs