我有一个如下数据框:
Date and Timestamp Name FP
NA <NA> <NA> NA
39 Jul 19,2017 2:25:08 PM 1500485400000 Unknown 0.004
40 Jul 19,2017 2:25:08 PM 1500486300000 Unknown 0.006
41 Jul 19,2017 2:25:08 PM 1500487200000 Unknown 0.003
42 Jul 19,2017 2:25:08 PM 1500488100000 Unknown 0.008
43 Jul 19,2017 2:55:01 PM 1500487200000 Unknown 0.002
44 Jul 19,2017 2:55:01 PM 1500488100000 Unknown 0.008
45 Jul 19,2017 2:55:01 PM 1500489000000 Unknown 0.006
46 Jul 19,2017 2:55:01 PM 1500489900000 Unknown 0.003
47 Jul 19,2017 4:24:38 PM 1500492600000 Unknown 0.008
48 Jul 19,2017 4:24:38 PM 1500493500000 Unknown 0.014
49 Jul 19,2017 4:24:38 PM 1500494400000 Unknown 0.017
50 Jul 19,2017 4:24:38 PM 1500495300000 Unknown 0.014
51 Jul 19,2017 5:01:48 PM 1500494400000 Unknown 0.007
52 Jul 19,2017 5:01:48 PM 1500495300000 Unknown 0.013
53 Jul 19,2017 5:01:48 PM 1500496200000 Unknown 0.018
54 Jul 19,2017 5:01:48 PM 1500497100000 Unknown 0.007
55 Jul 19,2017 5:01:48 PM 1500498000000 Unknown 0.012
56 Jul 19,2017 6:15:11 PM 1500499800000 Unknown 0.005
57 Jul 19,2017 6:15:11 PM 1500500700000 Unknown 0.012
58 Jul 19,2017 6:15:11 PM 1500501600000 Unknown 0.011
59 Jul 19,2017 6:15:11 PM 1500502500000 Unknown 0.007
我想根据日期/小时/ FPS列做一个ggplot图表。由于它已经组织好了,我想从第1行一直到行的顺序为4。 x轴为FP,y轴为日期/小时/ FPS,标签倾斜90度。
现在我有这个:
ggplot(databyname, aes(x = databyname$`Date and Timestamp`,
y = databyname$FP)) +
theme_bw() +
geom_line()+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
问题在于它尝试组织日期和时间戳而不是仅按行绘制图形。 FP没有显示。提前致谢。 图表:https://ibb.co/iqJd4k
答案 0 :(得分:1)
首先,您必须向ggplot添加重新排序,因此您需要在1-15的数据报中添加一列,以便按行重新排序。像这样:
c=nrow(databyname)
databyname$rowid<- 1:c
然后你用这个
绘制它ggplot(databyname, aes(x =reorder(databyname$`Date and Timestamp`,databyname$rowid), y = databyname$Total_Frames,group=1)) +
geom_point()+ geom_line()+ theme(axis.text.x = element_text(angle = 90, hjust = 1))+ggtitle(name2)+
xlab('Date and Timestamp')+ylab('Total Frames')+geom_line()