Creating a Graph
In R, graphs are typically created interactively.
# Creating a Graph
title("Regression of MPG on Weight")
The plot( ) function opens a graph widow and plots weight vs. miles per gallon.
The next line of code adds a regression line to this graph. The final line adds a title.
You can save the graph in a variety of formats from the menu
File -> Save As.
You can also save the graph via code using one of the following functions.
See input/output for details.
Viewing Several Graphs
Creating a new graph by issuing a high level plotting command (plot, hist, boxplot, etc.) will typically overwrite a previous graph. To avoid this, open a new graph window before creating a new graph. To open a new graph window use one of the functions below.
You can have multiple graph windows open at one time. See help(dev.cur) for more details.
Alternatively, after opening the first graph window, choose History -> Recording from the graph window menu. Then you can use Previous and Next to step through the graphs you have created.
You can specify fonts, colors, line styles, axes, reference lines, etc. by specifying graphical parameters. This allows a wide degree of customization. Graphical parameters, are coverd in the Advanced Graphs section. The Advanced Graphs section also includes a more detailed coverage of axis and text customization.