I have two set of time series data. I would like to plot them with respect to the time and date. Moreover, they are number of attributes (-1 or 1) for the corresponding time under the title of outlier and they should be presented with a symbol where outlier=”-1″ on the plot. Moreover, another problem in my code is in the Legend the title of the legend and one of the contents of the legend appeared similarly.
true pred outlier dtt
0.05 0 1 9/29/2007 0:00
-0.33 0 1 9/29/2007 1:00
-0.41 0 1 9/29/2007 2:00
-0.69 0 1 9/29/2007 3:00
-0.68 0 1 9/29/2007 4:00
-0.43 -0.53 1 9/29/2007 5:00
-0.12 -0.23 1 9/29/2007 6:00
0.15 0.16 1 9/29/2007 7:00
0.56 0.39 1 9/29/2007 8:00
0.98 0.87 1 9/29/2007 9:00
1.18 1.27 1 9/29/2007 10:00
2.14 1.31 1 9/29/2007 11:00
4.12 2.87 1 9/29/2007 12:00
5.59 5.43 1 9/29/2007 13:00
6.90 6.52 1 9/29/2007 14:00
6.40 7.80 1 9/29/2007 15:00
5.88 5.78 1 9/29/2007 16:00
6.14 5.58 1 9/29/2007 17:00
4.61 6.20 -1 9/29/2007 18:00
5.15 6.20 1 9/29/2007 19:00
2.74 4.54 -1 9/29/2007 20:00
4.66 4.54 1 9/29/2007 21:00
5.10 4.74 1 9/29/2007 22:00
4.79 5.53 1 9/29/2007 23:00
Applied code:
ggplot(second_data_results_node25, aes( second_data_results_node25$dtt)) +
geom_line(aes(y = second_data_results_node25$true, colour = "TRUE")) +
geom_line(aes(y = second_data_results_node25$pred, colour = "Prediction"))
Inorder to draw using
ggplot2, you’ll have to shape your data accordingly. Since you have two variables, you couldmeltthem (I usereshape2here to melt) and usegroupinggplot2as follows: