0

I am trying to plot multiple line on one chart.

They all have the same X- axis in months, but different observation for y-axis. I have tried writing this code but I keep on getting an error. Can someone point me towards what I am doing wrong?

"Test3" is the same of my data set, "Oil_1" represents the first Y observation, "Oil_2" second observation and "Month" is the X-axis

ggplot(test3, + aes(x = Months)) +
    geom_line(aes(y=oil_1),colour="blue")+
    geom_line(aes(y=oil_2),colour="red") +
    ylab(label="Production")+
    xlab("Months") 
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Nexus
  • 1

1 Answers1

0

You have an extra "+" before the first aesthetic call, that could be the problem.

Yazid
  • 101
  • 1
  • 4
  • it is still not working - – Nexus Oct 18 '19 at 14:39
  • I have tried a different way but now getting thsi error: geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic? – Nexus Oct 18 '19 at 14:39
  • I have used reshape to melt my data as I have two variable Months variable value 1 1 OIL_1 183 2 2 OIL_1 172 3 3 OIL_1 890 4 4 OIL_1 876 5 5 OIL_1 345 6 6 OIL_1 2406 then I am entering my ggplot code: ggplot(TEST3CC, aes(x = Months, y = value)) + geom_line(aes(color = variable, linetype = variable)) + scale_color_manual(values = c("darkred", "steelblue")) geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic? – Nexus Oct 18 '19 at 14:39