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

Adjusting axis annotations and tick marks


The default axis settings are often not adequate to deal with all kinds of data. For example, we might wish to change the number of tick marks along an axis or change the orientation of the annotations if they are too long in order to fit them horizontally. In this recipe, we will cover some settings that can be used to customize axes as per our requirements.

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...

We can set the xaxp and yaxp arguments with the par() command in order to specify coordinates of the extreme tick marks and the number of intervals between tick marks in the c(min,max,n) form:

plot(rnorm(100),xaxp=c(0,100,10))

How it works...

When xaxp or yaxp is not specified, R automatically calculates the number of tick marks and their values. By default, R extends the axis limits by adding...