0

I have two genotypes in my ggplot, and I want to assign them two different colours; q24 in black, q35 in green.

Here is my code:

ggplot(all,aes(x=Concentration, y=Distance, colour=Genotype))+
geom_jitter(width=0.3, height=0, show.legend=TRUE)+
theme(panel.background = element_rect(fill = "white")) +
theme(axis.line.x = element_line(color = "black"),
    axis.line.y = element_line(color = "black"))+
scale_y_continuous(breaks=seq(0, 8, 1))+
annotate("segment", x=0.8,xend = 1.2, y= 2.86, yend = 2.86, colour="black")+
annotate("segment", x=1.8,xend = 2.2, y= 1.86, yend = 1.86, colour="black")+
annotate("segment", x=2.8,xend = 3.2, y= 1.11, yend = 1.11, colour="black")+
annotate("segment", x=0.8,xend = 1.2, y= 2.41, yend = 2.41, colour="green")+
annotate("segment", x=1.8,xend = 2.2, y= 2.16, yend = 2.16, colour="green")+
annotate("segment", x=2.8,xend = 3.2, y= 2.24, yend = 2.24, colour="green")+
ggtitle("Distance travelled by Q24YFP and Q35YFP C. elegans at different 
caffeine concentrations")

My data looks like this:

Concentration   Distance    Genotype
0   1   Q24
0   4   Q24
0   1   Q24
5   4   Q24
5   4   Q24
10  0   Q24
10  1   Q24
5   3   Q35
5   1   Q35
10  0   Q35
10  2   Q35

How do I assign different colours to these two genotypes? Currently it prints them in two different colours, but not the ones I want.

Jasmine
  • 11
  • 1
  • 3
  • You probably want `scale_colour_manual(values = c(q24 ="black", q35="green))`. It would be easier to help if you provided a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample data so solutions can be tested. See [?scale_colour_manual](http://ggplot2.tidyverse.org/reference/scale_manual.html) – MrFlick Nov 17 '17 at 21:28
  • I apologise if I seem clueless but I am new to R! I have edited my post and added some sample data. – Jasmine Nov 17 '17 at 21:46
  • The issue is resolved from the code you gave me, thank you! – Jasmine Nov 17 '17 at 22:13

0 Answers0