i got a plot in R based on ggplot2. Unfortunately, I have not enough reputation here to upload the plot. Now, I want to change my legend title and the names of the labels for two lines.
Thus, I added scale_fill_continuous(name = "New Legend Title", labels=c("Control", "Treatment")) to the code.
ggplot(data=descripintens, 
aes(x=syear, y=workingintensity, group= treatment, colour=factor(treatment))) + 
geom_line() +
xlab("Year") +
ylab("Working intensity") +
scale_fill_continuous(name = "New Legend Title", labels=c("Control", "Treatment"))
This is what is suggested in stackoverflow and the ggplot2 cheat sheet. Nothing changes. Not even an error comes up.
What is wrong with my code?
Thank you!
EDIT: The data I used for the plot is a table, which is based on this code:
descripintens<-intensity141516 %>% 
  group_by(syear, treatment) %>%
  summarise(workingintensity=mean(intensity))
The table descripintens looks like this: 
   syear Treatment workingintensity
1  2014     0         96.2
2  2014     1         98.4
3  2015     0         101.00000
4  2015     1         102.00000
5  2016     0         105.9
6  2016     1         106.2
                You can try with this:
ggplot(data = descripintens
       ,aes(x = syear, y = workingintensity, group = treatment,colour = factor(treatment))) +
  geom_line() +
  xlab("Year") +
  ylab("Working intensity") + 
  labs(color='NEW LEGEND TITLE')  +
  # you should specify the color also
  scale_color_manual(labels = c("Control", "Treatment")
                     ,values = c("blue", "red"))

With data:
descripintens <- read.table(text ="   syear treatment workingintensity
1  2014     0         96.2
2  2014     1         98.4
3  2015     0         101.00000
4  2015     1         102.00000
5  2016     0         105.9
6  2016     1         106.2")
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With