
Hi Dennis, thanks! No, this looks good to me, with equal-sized panels. I didn't realize there was such a similar post before - all my queries had retrieved questions about dropping categories in panels... but this is great - thank you.All the best!Stephen

Date: Tue, 24 Aug 2010 12:58:20 -0700
Subject: Re: [R] drop unused levels in lattice dotplot axis?
From: djmuser@gmail.com
To: obsessively@hotmail.com
CC: r-help@r-project.org

Hi:

This looks to be a step in the right direction, but the resulting 
panels are all the same size. Perhaps you can build on it...

# Solution based on an R-help post by Deepayan Sarkar:
# http://tolstoy.newcastle.edu.au/R/e2/help/06/09/1579.html


dotplot(A ~ B | C, data=dfr, scales=list(y=list(relation="free")),
     prepanel = function(x, y, ...) {
        # drop unused levels
          yy <- y[, drop = TRUE]
       # reset y-limits

          list(ylim = levels(yy), 
               yat = sort(unique(as.numeric(yy))))
           },
     panel = function(x, y, ...) {
        # drop unused levels...again...
                yy <- y[, drop = TRUE]

                panel.dotplot(x, yy, ...)
               }
     )

HTH,
Dennis


On Tue, Aug 24, 2010 at 4:25 AM, Stephen T. <obsessively@hotmail.com> wrote:



Hi list, I have a data set - something like this

dfr <- data.frame(A=factor(letters[1:25]),B=runif(25),                  C=sample(LETTERS[1:4],25,replace=TRUE))

and I want to create a dotplot:

library(lattice)dotplot(A ~ B | C, data=dfr, scales=list(y=list(relation="free")))

but this puts uneven spaces along the y-axis in each panel. drop.unused.levels=TRUE will drop conditioning variables, but does not affect the levels in the y-variable.

I can get something like what I want with ggplot2:library(ggplot2)ggplot(data=dfr,mapping=aes(x=B,y=A)) + geom_point() +  facet_wrap( ~ C,scales="free_y")

I wonder if this is possible in lattice?

Thanks!

Stephen

        [[alternative HTML version deleted]]



______________________________________________

R-help@r-project.org mailing list



PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


 		 	   		  
	[[alternative HTML version deleted]]

