0

I want to combine a time series of in situ values (line) with boxplots of estimated values of special dates. I tried to understand this "Add a line from different result to boxplot graph in ggplot2" question, but my dates make me drive crazy. Sometimes I only have in situ values of a date, sometimes only estimated values and sometimes both together.

I uploaded a sample of my data here:

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

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

How can I create a plot with both data sets that looks like this http://www.file-upload.net/download-9942496/desired_outputplot.png.html in the end?

Community
  • 1
  • 1
Iris
  • 1,072
  • 3
  • 10
  • 22

1 Answers1

0

I got help and have a solution now:

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)))
Iris
  • 1,072
  • 3
  • 10
  • 22