Skip to content
Back to formatted view

Raw Message

Message-ID: <eb555e660803311304g650dad5fma6842e086ea9bcf3@mail.gmail.com>
Date: 2008-03-31T20:04:06Z
From: Deepayan Sarkar
Subject: adding device size-independent y=0 line to a lattice plot
In-Reply-To: <7a09e3940803311256j775617d6kc3c16de932560146@mail.gmail.com>

On 3/31/08, Levi Waldron <leviwaldron at gmail.com> wrote:
> Using the following lattice plot as an example, I would like to add
>  horizontal lines where y=0:
>
>  library(lattice)
>  library(grid)
>  fac <- gl(4,12)
>  x <- letters[rep(1:3,16)]
>  y <- runif(48,min=0.0)
>  dotplot(y~x|fac)
>
>  I've tried it with grid.lines using npc and native units, which works
>  fine unless I change the size of the output device - then the lines
>  are in the wrong place.  Is there a way to do this that is independent
>  of the output device size?

The obvious thing to try would be

dotplot(y~x|fac,
        panel = function(...) {
            panel.abline(h = 0)
            panel.dotplot(...)
        })

Does this not work?

-Deepayan