Scatterplots
This lesson is called Scatterplots, part of the Fundamentals of R (RStudio) course. This lesson is called Scatterplots, part of the Fundamentals of R (RStudio) course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Loading transcript...
View code shown in video
# Load Packages -----------------------------------------------------------
library(tidyverse)
# Import Data -------------------------------------------------------------
penguins <- read_csv("penguins.csv")
# Scatterplots ------------------------------------------------------------
# We use geom_point() to make a scatterplot.
ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm)) +
geom_point()
Your Turn
# Load Packages -----------------------------------------------------------
library(tidyverse)
# Import Data -------------------------------------------------------------
penguins <- read_csv("penguins.csv")
# Scatterplots ------------------------------------------------------------
# Make a scatterplot that shows flipper length on the x axis and body mass on the y axis.
# YOUR CODE HERE
Learn More
Claus Wilke talks about scatterplots in Chapter 12 of his book Fundamentals of Data Visualization. Michael Toth also has a long blog post about all of the ins and outs of making scatterplots in ggplot.
You can also find examples of code to make scatterplots on the Data to Viz website , the R Graph Gallery website , and in Chapter 5 of the R Graphics Cookbook.
Have any questions? Put them below and we will help you out!
Course Content
34 Lessons
1
The Grammar of Graphics
04:39
2
Scatterplots
03:46
3
Histograms
05:47
4
Bar Charts
06:37
5
Setting color and fill Aesthetic Properties
02:39
6
Setting color and fill Scales
05:40
7
Setting x and y Scales
03:09
8
Adding Text to Plots
07:32
9
Plot Labels
03:57
10
Themes
02:19
11
Facets
03:12
12
Save Plots
02:57
13
Bring it All Together (Data Visualization)
06:42
You need to be signed-in to comment on this post. Login.