Plot showing jumps between simulations
I have this issue with geom_path(). I want to plot a lot of simulations together, but for some reason when the plot is produced ggplot draws lines jumping between different simulations instead of following the correct simulation.
colnames(HIV.prev.HF.Rand.95) <- outMatRand[[1]]$time
HIV.prev.HF.Rand.95_m <- melt(HIV.prev.HF.Rand.95)
colnames(HIV.prev.HF.Rand.sat) <- outMatRand[[1]]$time
HIV.prev.HF.Rand.sat_m <- melt(HIV.prev.HF.Rand.sat)
And that melted data looks like this:
Var1 Var2 value
. . .
. . .
197 97 1986 0.001215456
198 98 1986 0.001277602
199 99 1986 0.001200965
200 100 1986 0.001247436
201 1 1987 0.001173847
202 2 1987 0.001301196
203 3 1987 0.001312864
204 4 1987 0.001544837
205 5 1987 0.001467538
206 6 1987 0.001509051
207 7 1987 0.001297585
208 8 1987 0.001538991
. . .
. . .
I plotted using geom_path()
HF.95.sim.plt <- ggplot() +
geom_point(data=as.data.frame(Fdata.prev1),aes(year,prev*100)) +
geom_errorbar(data=as.data.frame(Fdata.prev1), aes(x=year,y=prev*100,ymin=lw*100,ymax=up*100)) +
geom_path(data = HIV.prev.HF.Rand.95_m, aes(x = Var2, y = value*100, group = Var1),alpha = 0.2) +
geom_path(data = HIV.prev.HF.Rand.sat_m, aes(x = Var2, y = value*100, group = Var1),color='red') +
ylim(0,2)
HF.95.sim.plt
Is this just because I'm plotting a hundred simulations together?