Here is the data I am using and the code:
str(dfrev_benchmark2)
'data.frame': 20 obs. of 2 variables:
$ B_Vec : num 1 51 101 151 201 251 301 351 401 451 ...
$ revenue: num 31508 1606929 3182350 4757771 6333192 ...
str(dfaugrev2)
'data.frame': 20 obs. of 2 variables:
$ B_Vec : num 1 51 101 151 201 251 301 351 401 451 ...
$ revenue: num 45451 2317977 4590503 6863029 9135556 ...
str(dfjanrev2)
'data.frame': 20 obs. of 2 variables:
$ B_Vec : num 1 51 101 151 201 251 301 351 401 451 ...
$ revenue: num 18412 939015 1859618 2780220 3700823 ...
profitmonthly <- ggplot() +
geom_line(data=dfjanrev2, aes(x=dfjanrev2[,1], y=dfjanrev2[,2]),
color="#000666", size=1.3)+
geom_line(data=dfaugrev2, aes(x=dfaugrev2[,1], y=dfaugrev2[,2]),
color="#990033", size=1.3)+
geom_line(data=dfrev_benchmark2, aes(x=dfrev_benchmark2[,1], y=dfrev_benchmark2[,2]),
color="#006633", size=1.3)+
scale_y_continuous(labels = scales::dollar)+
scale_x_continuous(limits = c(0, 1000))+
xlab("Size of the battery")+
ylab("Profit") +
ggtitle("Size of the Battery vs Profit: Monthly Forecast Timespan") +
theme(plot.title=element_text(size = 15, face="bold"), axis.text=element_text(size=12),
axis.title=element_text(size=12,face="bold"))+
scale_color_manual(name = "Line Color",
labels = c("January"="#000666", "August"="#990033", "Yearly forecast"="#006633"))
print(profitmonthly)
It gives me this plot:
I have tried to put the color inside the aes
, but then the plot is empty and it does not read the data. So I guess scale_color_manual
is not useful here, since data is not factors.
I just need to create a simple legend describing the colors of the lines.