Add custom legend for two variables from the same data set in R

106 Views Asked by At

I tried to add custom legend into my R plot that uses same x value but two different y values. I used the approach from the following post but it does not work:

Custom legend for multiple layer ggplot

ggplot(combo_plot, aes(x))+
  geom_point(aes(y=y1),size=2,color="black")+
  geom_point(aes(y=y2),size=2,color="red")+
  coord_cartesian(xlim = c(0,1.25),ylim=c(200,450)) + 
  scale_x_continuous(breaks = seq(0,1.25,0.25), minor_breaks = seq(0,1.5,0.25),expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(200,450,25), minor_breaks = seq(200,450,25),expand = c(0, 0)) +
  scale_colour_manual(name = 'the colour', 
                      values =c('black'='black','red'='red'), labels = c('c2','c1'))+
  theme(plot.title = element_text(family = "GE Inspira", color="#666666", face="bold", size=16, hjust=0.5))+
  theme(axis.title = element_text(family = "GE Inspira", color="#666666", face="bold", size=12, hjust=0.5))

Any idea why it does not work in this case?

0

There are 0 best solutions below