rggplot2ggforce

change border thickness of marked ellipses created using ggforce::geom_mark_ellipse()


I am trying to change the borders of marked ellipses created using ggforce::geom_mark_ellipse(). How can I remove the borders and just keep the filled ellipses? code for reproducibility is provided below.

enter image description here

library(palmerpenguins)
library(tidyverse)
library(ggplot2)
library(ggforce)

penguins <- penguins %>%
  drop_na()
penguins %>% head() %>% print()


p <- penguins %>%
  ggplot(aes(x = bill_length_mm,
             y = flipper_length_mm))+
  geom_mark_ellipse(aes(colour=species, fill = species),
                   expand = unit(0.5,"mm"),
                   show.legend = F)+
  geom_point(aes(color = species))

print(p)

Solution

  • You could remove the outline or set the thickness via size, i.e. size=0 or size=NA will work to remove the outline. Another option would be to set the linetype to blank, i.e. lty = "blank".

    library(palmerpenguins)
    library(tidyverse)
    library(ggplot2)
    library(ggforce)
    
    penguins <- penguins %>%
      drop_na()
    
    p <- penguins %>%
      ggplot(aes(x = bill_length_mm,
                 y = flipper_length_mm))+
      geom_mark_ellipse(aes(colour=species, fill = species),
                        expand = unit(0.5,"mm"), size = 0,
                        show.legend = F)+
      geom_point(aes(color = species))
    
    print(p)