using trellis.last.object()$y.scales$log helps a lot, thanks! I now check whether data were transformed and apply an appropriate transformation if needed. Maybe it helps when current.panel.limit() has information about transformations, so someone doesn't need to call 'trellis.last.object()', too.
________________________________________ Von: Deepayan Sarkar <deepayan.sar...@gmail.com> Gesendet: Mittwoch, 23. März 2022 12:05 An: Ivan Krylov Cc: Garbade, Sven via R-help; Garbade, Sven Betreff: Re: [R] panel.rect and log scale in lattice plot On Wed, Mar 23, 2022 at 4:08 PM Ivan Krylov <krylov.r...@gmail.com> wrote: > > On Wed, 23 Mar 2022 09:38:34 +0000 > "Garbade, Sven via R-help" <r-help@r-project.org> wrote: > > > cpl <- current.panel.limits() > > If you str() the return value of current.panel.limits() from the panel > function with log-scaling enabled, you can see that it contains the > logarithm of the y-values, as do the y values themselves. This is > consistent with ?xyplot saying: > > >> Note that this is in reality 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)’. > > ...although it could be more explicit. > > If you take a logarithm of 10 and 500, lrect() should be able to > produce a rectangle in the right place. Right, "log scales" in lattice simply transform the data, unlike in traditional graphics. If it helps, I could change current.panel.limits() to return information on whether the data were transformed. For now, a roundabout way to detect this inside the panel function is to use trellis.last.object()$y.scales$log etc. Best, -Deepayan > > -- > Best regards, > Ivan > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.