1

If possible I'd like to do this within a ggplot and not mess with making a whole bunch of extra data.frames

I have the following example figure, I will be making figures like this a lot so need the ggplot function to be a bit muteable.

  example <- data.frame(origin = c(1,2,2,1,1,1,2,2,1,2,1,2),
                    frequency = c(0.5,0.6,0.05,0.1,0.1,0.1,0.1,0.05,0.1,0.15,0.1,0.05),
                    id_simple = c("a", "a", "b", "b", "c", "d", "c", "d", "Non Overlapping", 
  "Non Overlapping", "Low Frequency", "Low Frequency"))

  ggplot(example, aes(x = origin, y = frequency, group = id_simple, fill = id_simple))+
     geom_area(alpha = 0.6, size = 1, colour = "black")+
     theme_light()

enter image description here

I don't know how many samples each data frame will have or what their id_simple name will be. However, I know each one will have a sample with id_simple = "Low Frequency" and "Non-Overlapping". I would like to colour those two samples grey and black respectively.

the common solution seems to be Scale_fill_manual() however that requires me to provide a hardcoded list of colours and since the number of samples other than the two I want to colour will change I can't figure out how to use that.

TLDR, I want the fill colours that ggplot assigns to each sample except want the one with id_simple == "Low Frequency" to be grey and the one with id_simple == "Non Overlapping" to be black

3luke33
  • 37
  • 3

0 Answers0