Skip to Content
R in a Nutshell, 2nd Edition
book

R in a Nutshell, 2nd Edition

by Joseph Adler
October 2012
Beginner to intermediate
721 pages
21h 38m
English
O'Reilly Media, Inc.
Content preview from R in a Nutshell, 2nd Edition

Customizing Charts

There are many ways to change how R plots charts. The most intuitive is through arguments to a charting function. Another way to customize charts is by setting session parameters. An additional way to change a chart is through a function that modifies a chart (for example, adding titles, trend lines, or more points). Finally, it is possible to write your own charting functions from scratch.

This section describes common arguments and parameters for controlling how charts are plotted.

Common Arguments to Chart Functions

Conveniently, most charting functions in R share some arguments. Here is a table of common arguments for charting functions.

ArgumentDescription
addShould this plot be added to the existing plots on the device, or should the device be cleaned first?
axesControls whether axes will be plotted on the chart.
logControls whether points are plotted on a logarithmic scale.
typeControls the type of graph being plotted.
xlab, ylabLabels for x- and y-axes.
mainMain title for the plot.
subSubtitle for the plot.

Graphical Parameters

This section describes the graphical parameters available in the graphics package. In most cases, you can specify these parameters as arguments to graphics functions. However, you can also use the par function to set graphics parameters. The par function sets the graphics functions for a specific graphics device. These new settings will be the defaults for any new plot until you close the device.

The par function can be useful if you want to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R in a Nutshell

R in a Nutshell

Joseph Adler
The R Book, 2nd Edition

The R Book, 2nd Edition

Michael J. Crawley
The R Book

The R Book

Michael J. Crawley
R Packages

R Packages

Hadley Wickham

Publisher Resources

ISBN: 9781449358204Errata Page