Book Image

ggplot2 Essentials

By : Donato Teutonico
Book Image

ggplot2 Essentials

By: Donato Teutonico

Overview of this book

Table of Contents (14 chapters)
ggplot2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Axis scales


Together with axis labels, you will also often need to change the axis scales. For instance, you may want to change the scale in log values or modify the default range values included in the axis when creating the plot. In this section, we will take a look at exactly how to do these modifications. The axis scales as well as the legends are derived from the scales used in aesthetic mappings, so, in many cases, if you want to manipulate such values, you will need to use the scale function relative to your specific situation. For this reason, we will treat the plots with only discrete scales as different from those with only continuous scales.

The discrete axis

You may have a plot with discrete scales, for instance, when you represent data grouped in categories along one of the axes. As an example, we will use the dataset with the four different normal distributions that we created in the previous chapter with the next command. In this case, we will just directly define the grouping...