+ - 0:00:00
Notes for current slide
Notes for next slide



More ggplot

Dr. Mine Dogucu

1 / 12

  • Using the penguins data,
  • Map bill depth to x-axis, bill length to y-axis, species to shape and color.
  • Add a layer of points and set the size of the points to 4.
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point(size = 4)
2 / 12

Labs

  • Using the penguins data,
  • Map bill depth to x-axis, bill length to y-axis, species to shape.
  • Add a layer of points and set the size of the points to 4.
  • Add labels to x-axis (Bill Depth(mm)), y-axis (Bill Length(mm)), and the title of the plot (Palmer Penguins).
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point(size = 4) +
labs(x = "Bill Depth (mm)",
y = "Bill Length (mm)",
title = "Palmer Penguins")
3 / 12
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point() +
labs(x = "Bill Depth (mm)",
y = "Bill Length (mm)",
title = "Palmer Penguins") +
theme_bw()

4 / 12
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point() +
labs(x = "Bill Depth (mm)",
y = "Bill Length (mm)",
title = "Palmer Penguins") +
theme_bw() +
theme(text = element_text(size=20))

6 / 12
?theme
7 / 12
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point(size = 4) +
facet_grid(.~species)

8 / 12
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point(size = 4) +
facet_grid(species~.)

9 / 12

You can do much more in ggplot.

  • Use images
  • Make maps
  • Pick colors that you want
10 / 12

You can do much more in ggplot.

  • Use images
  • Make maps
  • Pick colors that you want

We don't have time to cover all these. However, as we go along, you will become fluent in reading R code and Googling. You can always ask me too.

11 / 12

You can do much more in ggplot.

  • Use images
  • Make maps
  • Pick colors that you want

We don't have time to cover all these. However, as we go along, you will become fluent in reading R code and Googling. You can always ask me too.

Check out the ggplot flipbook for some inspiration.

12 / 12

  • Using the penguins data,
  • Map bill depth to x-axis, bill length to y-axis, species to shape and color.
  • Add a layer of points and set the size of the points to 4.
ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
shape = species,
color = species)) +
geom_point(size = 4)
2 / 12
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow