[R] plotting predicted curves with log scale in lattice

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Sep 4 01:27:45 CEST 2007


On 9/3/07, Ken Knoblauch <knoblauch at lyon.inserm.fr> wrote:
> Hi,
>
> I was taken off guard by the following behavior in a lattice plot.
> I frequently want to add a predicted curve defined at more
> points than in the formula expression of xyplot.  There have
> been numerous examples of how to do this on r-help, but I
> still often struggle to make this work.  I just realized that
> specifying one of the axes on a log scale does not guarantee
> that the added data for a curve will automatically take that
> into account.  I don't know if this should be called a bug,

More like a possibly desirable feature that's missing.

> I haven't picked up an indication that would lead me to
> expect this in the documentation.

Yes, the documentation is a bit vague. I've changed it to the
following, which is hopefully clearer.

          'log' Controls whether the corresponding variable ('x' or
               'y') will be log transformed before being passed to the
               panel function.  Defaults to 'FALSE', in which case the
               data are not transformed.  Other possible values are any
               number that works as a base for taking logarithm, 'TRUE'
               (which is equivalent to 10), and '"e"' (for the natural
               logarithm).  As a side effect, the corresponding axis is
               labeled differently.  Note that this is a transformation
               of the data, not the axes.  Other than the axis
               labeling, using this feature is no different than
               transforming the data in the formula; e.g.,
               'scales=list(x = list(log = 2))' is equivalent to 'y ~
               log2(x)'.

-Deepayan



More information about the R-help mailing list