[R] plot multiple data sets on same axis

Scott Lamb slamb at slamb.org
Mon Dec 31 02:49:17 CET 2007


Scott Lamb wrote:
> I've tried replacing the for loop body with this:
> 
>     this_method <- split.df[[i]]
>     boxplot(elapsed~inactive, data=this_method,
>             add=TRUE, border=i, boxfill=i, outline=FALSE)
> 
> but it has two problems:
> 
> * it doesn't plot at the correct x values. It looks like I need to
> supply a list of the x values as the "at" parameter, and I don't know
> how to get unique values from this_method$inactive. (I tried the clunky
> labels(split(this_method, this_method$inactive)), but it returns them as
> strings.)

Ahh. I missed the obvious answer - there's a function called unique.
at=unique(this_method$inactive) works.

> 
> * it redraws the graph's frame, and it ignores bty="l" when doing so.

also the x axis tics and labels...they're totally unreadable now.

Cheers,
Scott

-- 
Scott Lamb <http://www.slamb.org/>



More information about the R-help mailing list