Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ggplot2 Essentials

You're reading from   ggplot2 Essentials Explore the full range of ggplot2 plotting capabilities to create meaningful and spectacular graphs

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785283529
Length 234 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Donato Teutonico Donato Teutonico
Author Profile Icon Donato Teutonico
Donato Teutonico
Arrow right icon
View More author details
Toc

Legends


As we mentioned in Chapter 3, The Layers and Grammar of Graphics, legends are guides that represent the inverse of the applied scales and are used to trace back the plot elements to the aesthetic mapping. For this reason, legends are defined in ggplot2 as guides since they represent guides to the aesthetic mapping. The legend that is created by ggplot2 depends on the aesthetic mapping and the geometry that is used in the plot. For instance, Figure 5.1 contains a continuous color scale, Figure 5.2 contains boxplots, and Figure 5.4 contains points.

Since legends are recreated by scale functions, most of the time you will need to use scale functions to modify the legend's appearance. In this section, we will go through how to change the four main aspects of legends: the title, labels, legend box, and legend position. But, first of all, let's see how we can remove the legend.

To remove the legend, you can use the guide argument of the scale function or directly use the guides() function...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image