Book Image

R Graphs Cookbook Second Edition

Book Image

R Graphs Cookbook Second Edition

Overview of this book

Table of Contents (22 chapters)
R Graphs Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Choosing box styles


The styles of various boxes drawn in a graph such as the one around the plotting region and the legend can be adjusted in a similar way to the line styles we saw in the last recipe.

Getting ready

All you need to try out in this recipe is to run R and type the recipe in the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.

How to do it...

Let's say we want to create an L-shaped box around a graph such that the default top and right borders are not drawn. We can do so using the bty argument in the par() command:

par(bty="l")
plot(rnorm(100))

How it works...

The bty argument stands for the box type and takes single characters in inverted commas as values. The resulting box resembles the corresponding uppercase letter. For example, the default value is o, thus creating a box with all four edges. Other possible values are l, 7, c, u, and ]. If we do not wish to draw a box at all, we can set bty to n.

Note

Note that setting bty...