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 histogram styles – bar colors, borders, and axes


The default styling of histograms does not look great and might not be suitable for publications. In this recipe, we will learn how to improve the look by setting bar colors and borders, and adjusting the axes.

Getting ready

Once again we will use the airpollution.csv example. So, let's make sure it is loaded by running the following command at the R prompt:

air<-read.csv("airpollution.csv")

How to do it...

Let's visualize the probability distribution of respirable particle concentrations with black bars and white borders:

hist(air$Respirable.Particles,
prob=TRUE,col="black",border="white",
xlab="Respirable Particle Concentrations",
main="Distribution of Respirable Particle Concentrations")

How it works...

By now, you might have guessed how to do this yourself. We used the col and border arguments to set the bar and border colors to black and white, respectively.

There's more

You might have noticed that, in all of the previous examples...