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 plotting point symbol styles and sizes


In this recipe, we will see how we can adjust the styling of plotting symbols, which is useful and necessary when we plot more than one set of points that represent different groups of data on the same graph.

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. We will also use the cityrain.csv example data file that we used in the first chapter. Please read the file into R as follows:

rain<-read.csv("cityrain.csv")

How to do it...

The plotting symbol and size can be set using the pch and cex arguments:

plot(rnorm(100),pch=19,cex=2)

How it works...

The pch argument stands for the plotting character (the symbol). It can take numerical values (usually between 0 and 25) as well as single character values. Each numerical value represents a different symbol. For example, 1 represents circles, 2 represents triangles...