在一个图中绘制两个数据集时遇到问题。第二个数据集(B(57,4))来自第一个数据集(2000 +,10)(平均值,标准差)。最后,我希望得到这样的数字:
现在我使用下面的代码绘制第二个日期集:
my.data<-read.table(paste(i,"myTS.dat",sep = ""),header = TRUE)
x<-my.data$time
y<-my.data$wl
sd<-my.data$wlsd
tiff(paste(i,".tiff",sep = ""),height=3815,width=4305,unit='px',compression="lzw",res=360)
gg<-qplot(x,y,xlab = "time",ylab = "Elevation")
gg_type1<-geom_line(colour = "blue",size = 0.5)
gg_type2<-geom_point(size = 3,shape=21,fill="white")
gg_bar<-geom_errorbar(aes(x = x,ymin = y-sd,ymax=y+sd),colour = "red",width=0.05)
gg_theme<-theme_set(theme_bw())+ theme(panel.grid.major=element_line(colour=NA))
p<-gg+gg_type1+gg_type2+gg_bar+gg_theme
print(p)
dev.off()
得到这样的数字:
如何将第一个数据集添加到图中,就像第一张图片中的灰点一样?我尝试了这个,但它没有用。
origin<-read.table(paste("origin_",i,".txt",sep = ""),header = TRUE)
xo<-(origin$time)
yo<-(origin$height)
p<-gg+gg_type1+gg_type2+gg_bar+gg_theme+geom_point(aes(xo,yo))
非常感谢任何建议或帮助。谢谢。
好的,我把my.data
放在这里:
structure(list(time = c(2010.586, 2010.74, 2010.819, 2010.822,
2010.901, 2011.052, 2011.132, 2011.205, 2011.285, 2011.364, 2011.444,
2011.518, 2011.597, 2011.677, 2011.748, 2011.827, 2011.83, 2012.06,
2012.063, 2012.142, 2012.213, 2012.292, 2012.372, 2012.525, 2012.604,
2012.683, 2012.757, 2012.836, 2013.066, 2013.068, 2013.148, 2013.219,
2013.299, 2013.381, 2013.452, 2013.46, 2013.532, 2013.611, 2013.69,
2013.844, 2013.923, 2013.997, 2014.077, 2014.156, 2014.23, 2014.307,
2014.389, 2014.46, 2014.468, 2014.54, 2014.622, 2014.701, 2014.773,
2014.852, 2014.855, 2014.934, 2015.085), wl = c(4716.69614519141,
4717.18695721942, 4716.95137413031, 4716.95215915847, 4716.95617293713,
4716.73451112085, 4716.91538177926, 4717.00588936267, 4716.78311524661,
4716.88238213472, 4716.98192878285, 4716.97499735093, 4716.96400457306,
4717.15611670712, 4716.99386029174, 4717.05634753127, 4716.96808398258,
4717.3385179692, 4716.69473283737, 4717.0563764012, 4716.97307380063,
4717.54419855758, 4716.6528308359, 4716.79914374548, 4716.87207534116,
4716.70372924768, 4716.88957602414, 4716.77689686401, 4717.089005203,
4716.79885280683, 4717.32157811021, 4716.4542772104, 4716.57303829829,
4716.69165719355, 4716.75878030774, 4716.51425619761, 4716.69628661921,
4716.76718193149, 4716.83711216341, 4716.56437245363, 4716.80095589741,
4716.92953229352, 4716.54242002516, 4719.15933244319, 4716.60029813372,
4716.77020818021, 4716.46140477099, 4716.89015101807, 4717.00917071744,
4716.45796269575, 4716.71523494857, 4716.42773085329, 4716.16425299646,
4716.56107921007, 4716.89280970058, 4716.72261405892, 4716.88387012439
), wlsd = c(0.216549886343437, 0.0482189681060723, 0.0588960842643573,
0.175719434105253, 0.0512158233301561, 0.0392292465112816, 0.0595950831354654,
0.0607877904822251, 0.0370930552408838, 0.617268490833093, 0.0383914957042668,
0.605527813866314, 0.0543574451035527, 0.0545768826476366, 0.0507742835767385,
0.0583394912905697, 0.0563566145080252, 0.0912149956407483, 0.0448705108316624,
0.069484057343461, 0.0458673635595506, 0.0758663652549518, 0.0379866112968593,
0.706702525314332, 0.0424187676989381, 0.0371769559424733, 0.0593394645898105,
0.0502308178338169, 0.0539188048527388, 0.0557205808317756, 0.0960199790307439,
0.0377344405056613, 0.623137480604024, 0.0450269480801559, 0.0638249721374399,
0.0375489717974975, 0.0376544472258395, 0.622074959650495, 0.186283259878619,
0.0492906734226584, 0.0523743622696856, 0.0486222624919726, 0.115848182732971,
0.115018243869508, 0.0427547194026263, 0.0702039197853462, 0.0414918973327205,
0.0520070741917287, 0.0585758170986699, 0.0377079876736141, 0.0392247467180624,
0.616261504979872, 0.263302559470029, 0.0486800241034257, 0.0514939409350517,
0.0509628426691605, 0.0480276613429565)), .Names = c("time",
"wl", "wlsd"), class = "data.frame", row.names = c(NA, -57L))
原始数据发布时间很长。与my.data
类似,但包含更多行。