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
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Applied Data Visualization with R and ggplot2

You're reading from   Applied Data Visualization with R and ggplot2 Create useful, elaborate, and visually appealing plots

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher
ISBN-13 9781789612158
Length 140 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dr. Tania Moulik Dr. Tania Moulik
Author Profile Icon Dr. Tania Moulik
Dr. Tania Moulik
Arrow right icon
View More author details
Toc

Chapter 2:  Grammar of Graphics and Visual Components

The following are the activity solutions for this chapter.

Activity: Applying Grammar of Graphics to Create a Complex Visualization

Steps for Completion:

  1. Use the commands that we just explored to create the scatterplot.
  2. For this activity, you will use the gapminder dataset.
  3. You can use the help command to explore the options.
  4. To change scales, you will have to use one of the preceding label formats.
  5. Use labels=scales::unit_format ("K", 1e-3)) for labeling.

Outcome:

The output code is as follows:

ggplot(df, aes(x=gdp_per_capita,y=Electricity_consumption_per_capita))+
geom_point()+
scale_x_continuous(name="GDP",breaks = seq(0,50000...
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