+1 vote
in Programming Languages by (40.5k points)

I am trying to generate a line plot using the following code. But it generates a scatter plot instead of a line plot and gives the following error/warning message:

geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

plt <- ggplot(df, aes(x=truefracs, y=mean_est_fracs, color=Algorithms)) + 

    geom_line() +

    geom_point()

What is missing in the above code to get a line plot? 

1 Answer

+3 votes
by (71.8k points)
selected by
 
Best answer

Your aes() is missing the group parameter. That's why it generates a scatter plot instead of a line plot. From your code, it seems that you are using Algorithms as legends. So, add "group=Algorithms" to get the line plot.

Here is the modified code:

plt <- ggplot(df, aes(x=truefracs, y=mean_est_fracs, group=Algorithms, color=Algorithms)) + 

    geom_line() +

    geom_point()

Related questions

+1 vote
1 answer
+3 votes
1 answer
+1 vote
1 answer
+1 vote
1 answer
+5 votes
1 answer

...