0

I've been developing this graphic in R using ggplot2 for a few days now. I am almost done but I am having a problem. Enter image description here.

I have no idea how to get rid of those lines that keep crossing over. From what I can see, they are connecting the last point of a color to the next point that is that same color. It's not a problem for colors that do not repeat in the graph, but for the ones that do it does.

Here's what my script looks like:

section <- factor(p04_NoNegative$GS_Field, c("Out of Bounds", "High Weeds","Short Hieght","Low Thin",
        "Low Weeds","High Thin","Down","High Moisture","Medium Thin","Tall Hieght","Medium Weeds","Clumping","Low Moisture"))

x_axis_ef <- seq(0,6000,500)

#Speed
ggplot(p04_NoNegative, aes(x=Distance.Traveled, y=GS_VehicleSpeed)) + 
  geom_line(aes(color = section, group = section)) + 
  ggtitle("p04 entire field") + ylim(0,3) +
  ylab("Speed (m/s)")+ xlab("Distance (m)") + 
  scale_x_continuous(breaks = x_axis_ef) + 
  coord_cartesian(xlim = c(0,5000))

All of the colored areas of the graphs have a factor value in the section vector. The gray areas in the graph have no factor value and are showed as <NA> when I view the vector.

Chase Grimm
  • 417
  • 3
  • 14

0 Answers0