0

I'm using ggplot2 in order to make a line plot (y=sum of income, x=date)with points representing sales (y=intersection of line plot, x=promotiondate).

I have another column that represents the type of promotion and I want to change the color of points by the different values of this column.

p1<- ggplot(df,aes(x= date,y = income))

p1 + geom_line(col="red") + 
  geom_point(aes(x=df$promotiondate, y=df$income))+
  scale_color_manual(name="promotioncode", values = c("0"="white","P_1##1##1"="red","P_120##1##1"="blue","P_21##1##1"="green", "P_30##1##1"="yellow", "P_50##1##1"="purple", "P_66##1##1"="black"), labels=c("0","P_1##1##1","P_120##1##1","P_21##1##1", "P_30##1##1", "P_50##1##1", "P_66##1##1"))

This is what I obtain

enter image description here

As you can see all the points are black.

How can I make the colour of the points change based on the values of the columns promotioncode?

Thanks in advance

www
  • 38,575
  • 12
  • 48
  • 84
Filippo Leoncini
  • 347
  • 3
  • 15

0 Answers0