How to make a scatter plot with specific shapes with scale_shape_manual?

Hi,
How do I make a scatter plot with a filled triangle, filled circle, and filled upside down triangle shapes with scale_shape_manual?
I've got close, but can't work out how to get them filled in.

library(palmerpenguins)
library(tidyverse)
p <- penguins |> 
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm, 
        y = body_mass_g,
        colour = species,
        shape = species)
  )

p +
  scale_shape_manual(values = c(24, 19, 6))
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-03-01 with reprex v2.1.0

Try using the fill aesthetic instead of color.

library(palmerpenguins)
library(tidyverse)
p <- penguins |> 
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm, 
        y = body_mass_g,
        fill = species,
        shape = species)
  )

p +
  scale_shape_manual(values = c(24, 19, 25))
#> Warning: Removed 2 rows containing missing values (`geom_point()`).

Created on 2024-02-29 with reprex v2.0.2

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.