0

It's my first question in stackoverflow. I'm beginner in R. So, Maybe my question is very simple thing about yours.

my data set is as following..

Time    Inflow  Outflow
0   0   0
1   5   3
2   35  15
3   90  35
4   97.5    45
5   80  59.5
6   45  60
7   22.5    50
8   12.5    40
9   2.5 30
10  0   25
11  0   15
12  0   7.5
13  0   5
14  0   0

And I plot line graph using ggplot2 packages.

enter image description here

but there is no legend...

How I can display legend in this graph?

my code is

library(dplyr)
library(ggplot2)

example1.1 <- read.delim("C:/Users/USER/Downloads/example1.1.txt", header=TRUE)
example1.2 <- example1.1 %>% mutate(S = (Inflow - Outflow)*3600)
example1.3 <- data.frame(example1.2)
gg1 <- ggplot(example1.3, aes(x=Time, y=Inflow, group=1)) + 
  geom_line(color="blue")
gg2 <- gg1 + geom_line(aes(x=Time,y=Outflow, group=1), color="red")
gg3 <- gg2 + xlab("Time") + ylab("cms")
Gregor Thomas
  • 119,032
  • 17
  • 152
  • 277
Boram
  • 11

0 Answers0