[R] Line over Boxplot

Greg Snow 538280 at gmail.com
Thu Sep 20 19:15:46 CEST 2012


I expect that the coordinate system being set up and used by boxplot
is different from what you are expecting.  See the ?boxplot and ?bxp
help pages for details.  You may be able to have the boxplots drawn
where you expect by using the "at" argument (you may want to specify
"xlim" as well).

On Thu, Sep 20, 2012 at 7:41 AM, gfishel <gfishel at wral.com> wrote:
> Very much a rookie at R, and have only recently started using it again so
> pardon the simple question. I am trying to produce a box plot from one data
> set and then overlay a line plot from another data set. The box plot data
> set is made up of 20 sets of 30 data points, or 600 total data points. The
> line has only 30 total data points. The box plot is plotting fine, but for
> some reason, the line plot is starting at the 6th data position and running
> off the screen. I tried modifying the text file so that the data repeated it
> self 30 times to make the total number of lines in the file identical, but
> that did not help! Here are my two datasets.....
>
> temp.final.text
> <http://r.789695.n4.nabble.com/file/n4643736/temp.final.text>
> tmax.final.text
> <http://r.789695.n4.nabble.com/file/n4643736/tmax.final.text>
>
> And here is my script....
>
> R   --save --no-save --vanilla  <<  EOF
>
> pdf(file="boxplot_tmax_$YYYY$MM$DD${HH}.pdf", height=10, width=12)
>
> soton.df = read.table ("tmax.final.text", header=TRUE)
> gfs.df = read.table ("greg.txt", header=TRUE)
> boxplot (TMAX ~ HOUR, data=soton.df, xlab="Forecast Hour", ylab="MAX TEMP",
> main="GEFS $YYYY$MM$DD ${HH}Z FORECAST MAX TEMPS", whiskcol="red",
> col="red", outline=TRUE, ylim=c(0,100),xlim=c(1,30),xaxs="i",yaxs="i")
> lines (data=gfs.df, type="o", col="green")
> par(new=TRUE)
> abline(h=seq(0,100,by=5),lty=2)
> abline(v=seq(1,30,by=1),lty=2)
>
>
>
> EOF
>
> Thanks for  helping me out!
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Line-over-Boxplot-tp4643736.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com




More information about the R-help mailing list