Your geom_point
and geom_line
inherits its aesthetics from the "global" one provided in the ggplot
-call. In other words, the rows in the data frame gets divided into groups, based on your Section
, for both geom_point
and geom_line
.
One solution is to move the color-specification to to geom_point, ie.
ggplot(aes(x=DateTime, y=Array)) +
geom_point(aes(color=Section)) +
geom_line()
This the color of the line connecting all the dots is black -- the same color for all rows.
If you want the line connecting the dots to have the same color as the dots, you have to ask yourself: A line that connects two dots of different color, what color should the line have?
If you can "nøjes" with "intersection"-lines being black, we can draw colored lines on top of the black ones:
ggplot(aes(x=DateTime, y=Array)) +
geom_point(aes(color=Section)) +
geom_line() + # black line between all dots
geom_line(aes(color=Section)) # a *new* set of lines, which are drawn *on top*, but only "within" each section.