ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”

you only have to add group = 1 into the ggplot or geom_line aes(). For line graphs, the data points must be grouped so that it knows which points to connect. In this case, it is simple — all points should be connected, so group=1. When more variables are used and multiple lines are drawn, the grouping … Read more

ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”

You only have to add group = 1 into the ggplot or geom_line aes(). For line graphs, the data points must be grouped so that it knows which points to connect. In this case, it is simple — all points should be connected, so group=1. When more variables are used and multiple lines are drawn, the grouping … Read more

ggplot wrong color assignment

As you want to supply color names to argument colour= and display also a legend for this argument, you should add scale_colour_identity() to your last line in function. This scale ensures that values supplied will be interpreted as actual color values. Adding of argument breaks=cols_hex in function scale() will ensure ordering of names in legend.