Day 7 of viz with me

Data viz Beginner ggplot scatterplot shape DataViz Challenge

Today, we will explore going beyond using colors to represent groups.

Soundarya Soundararajan true
2024-10-07

Welcome to Day 7 of “Viz with Me”!

Yesterday, we learnt how to use colors to represent groups in a plot.

Goals for today: Instead of using colors to differentiate the groups in a plot, are there other ways to do so?

Yes! There are two additional methods:

  1. Changing the shape of the groups.

  2. Plotting the groups separately.

Today, we’ll focus on the first method: changing the shape.

Here’s an example:

library(tidyverse)
library(palmerpenguins)
penguins %>%
  ggplot(aes(bill_length_mm, body_mass_g)) +
  geom_point(aes(shape = species))

In this plot, instead of using colors, we are using shape to differentiate between the three species of penguins. If you’d like, you can also add colors to the plot like this:

penguins %>%
  ggplot(aes(bill_length_mm, body_mass_g)) +
  geom_point(aes(shape = species, color = species))

Sometimes, we do not want to use colors in our plots but still need a way to differentiate the groups, especially in scatter plots. This method of using shapes is a great alternative.

Alright, that’s all for today! I’ll see you tomorrow with another type of chart. Don’t forget to save your script for today’s lesson!

Jump to day 8 of “Viz with Me” here.

Photo by Magda Ehlers

Citation

For attribution, please cite this work as

Soundararajan (2024, Oct. 7). My R Space: Day 7 of viz with me. Retrieved from https://github.com/soundarya24/SoundBlog/posts/2024-10-07-day-7-of-viz-with-me/

BibTeX citation

@misc{soundararajan2024day,
  author = {Soundararajan, Soundarya},
  title = {My R Space: Day 7 of viz with me},
  url = {https://github.com/soundarya24/SoundBlog/posts/2024-10-07-day-7-of-viz-with-me/},
  year = {2024}
}