[R] Basic graphs: something like groups, but where each plot has independent axis?

Dylan Beaudette debeaudette at ucdavis.edu
Thu Mar 25 17:37:24 CET 2010


On Thursday 25 March 2010, Ben Bimber wrote:
> I am trying to graph weight data for our colony.  We a data frame with
> Animal, Weight and Date.  I'd like to display this data a series of simple
> xyplots.  We only need to display these plots together, we do not need to
> make comparisons between animals.  Each animal has been weighted over a
> different time period, so we do not want the same range for each X axis.
>
>
> Using the following, I can create one plot per animal:
>
> size <- length(unique(data$id))
> xyplot(weight ~ date | id,
>     data=data,
>     #type="o",
>     layout=c(1,size),
>     xlab="Date",
>     ylab="Weight"
>     );
>
> However, they share a common X axis.  Is it possible to avoid this?  In
> other words, I might want the first animal's plot to extend from 2008-01-01
> through 2009-05-04, while the second plot extends from 2007-02-04 through
> 2010-01-01.

Hi,

Be sure to see the scales argument in the manual page for xyplot(). Here is 
one approach to getting different scales on the x-axis:

xyplot(weight ~ date | id,
    data=data,
    layout=c(1,size),
    xlab="Date",
    ylab="Weight",
    scales=list(x=list(relation="free"))
    )

I think that there is a 'space' argument to most of the lattice plotting 
functions, but be sure to check the manual page. Another great resource is 
this website: http://lmdvr.r-forge.r-project.org/figures/figures.html

Cheers,
Dylan


> Also, can I introduce more whitespace between each plot?
>
> Thank you for any help.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341



More information about the R-help mailing list