Home > Mobile >  I created my own data frame, how can I create a legend in the ggplot?
I created my own data frame, how can I create a legend in the ggplot?

Time:03-30

I have created my own data.frame and trying to plot it. However, I just cant get my legend to pop up.

I think something is wrong on the case of the data.frame part.. but not clear

Could anyone please help me?

data <- data.frame(x=c(1, 2, 3, 4, 5),
                y1=c(1, 3, 5, 6, 3),
                y2=c(2, 4, 1, 3, 4))
data

data_plot <- ggplot(data, aes(x), col=group)   geom_smooth(aes(y=y1), color='black')   geom_smooth(aes(y=y2), color='blue')   labs(x="xxx", y="yyy", title="I need help")

data_plot

enter image description here

Sample data:

data <- data.frame(x=c(1, 2, 3, 4, 5),
                   y1=c(1, 3, 5, 6, 3),
                   y2=c(2, 4, 1, 3, 4))
data
  • Related