簡體   English   中英

在R中繪制方框圖和時間序列數據線

[英]Plot boxplots and line of time series data in R

我想將原位值(線)的時間序列與特殊日期的估計值的箱線圖結合起來。 我試圖理解這個“ 將不同結果的行添加到ggplot2中的boxplot圖中 ”的問題,但是我的約會使我發瘋。 有時我只有日期的原位值,有時只有估計值,有時兩者都有。

我在這里上傳了數據樣本:

http://www.file-upload.net/download-9942494/estimated.txt.html

http://www.file-upload.net/download-9942495/insitu.txt.html

到底如何使用兩個數據集創建一個圖,該圖看起來像http://www.file-upload.net/download-9942496/desired_outputplot.png.html

我得到了幫助,現在有一個解決方案:

insitu <- read.table("insitu.txt",header=TRUE,colClasses=c("Date","numeric"))
est <- read.table("estimated.txt",header=TRUE,colClasses=c("Date","numeric"))


insitu.plot <- xyplot(insitu~date_fname,data=insitu,type="l",
          panel=function(x,y,...){panel.grid(); panel.xyplot(x,y,...)},xlab=list(label="Date",cex=2))
est.plot <- xyplot(estimated~date,data=est,panel=panel.bwplot,horizontal=FALSE)
both <- insitu.plot+est.plot

update(both,xlim=range(c(est$date,insitu$date_fname))+c(-1,1),ylim=range(c(est$estimated,insitu$insitu)))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM