Re: [R] Lattice: merged strips?

From: Mike Lawrence <Mike.Lawrence_at_dal.ca>
Date: Fri, 11 Jul 2008 22:16:39 -0300

Aha! With the help of Deepayan's ever-insightful hints, I was able to do exactly what I wanted:

dotplot(

	variety ~ yield | site * year

, data = barley
, subset = (site %in% c("Grand Rapids", "Duluth"))
, layout=c(4, 1)
, scales=list(
alternating = F , tck =c(1, 0) , x = list(at=c(20, 30)) )
, strip = function(
which.given , which.panel , var.name , factor.levels , ... ){ if(which.given == 1){ strip.default( which.given = which.given , which.panel = which.panel , var.name = var.name , factor.levels = factor.levels , ... ) }else{ if(which.panel[1] == 1){ panel.rect(0, 0.5, 1, 1, col = "grey", border = "transparent") panel.lines(x = c(0, 0), y=c(0, 1), col='black') panel.lines(x = c(0, 1), y=c(1, 1), col='black') } if(which.panel[1] == 2){ panel.rect(0, 0.5, 1, 1, col = "grey", border = "transparent") panel.lines(x = c(0, 1), y=c(1, 1), col='black') panel.lines(x = c(1, 1), y=c(1, 0), col='black') panel.text(0, 0.75, labels = factor.levels[which.panel[2]]) } } }

)

On 11-Jul-08, at 8:52 PM, Deepayan Sarkar wrote:

> On 7/10/08, Mike Lawrence <Mike.Lawrence_at_dal.ca> wrote:
>> As I understand it, Duncan MacKay's solution involves simply  
>> pasting the
>> factors together, as in:
>>
>> |_AX_|_AY_|_BX_|_BY_|
>>
>> Which isn't quite as aesthetically pleasing as what I I'm looking  
>> for:
>>
>> |___A___|___B___|
>> |_X_|_Y_|_X_|_Y_|
>>
>> Any further suggestions?
>
> There is no easy way, especially if you want a general solution, but
> for your specific example, here is a possible starting point:
>
>
> dotplot(variety ~ yield | site * year, data = barley,
>        subset = (site %in% c("Grand Rapids", "Duluth")),
>        strip = function(which.given, which.panel,
>                         var.name, factor.levels, ...) {
>            str(list(which.given = which.given,
>                     which.panel = which.panel,
>                     var.name = var.name,
>                     factor.levels = factor.levels, ...))
>            if (which.given == 1)
>                strip.default(which.given = which.given,
>                              which.panel = which.panel,
>                              var.name = var.name,
>                              factor.levels = factor.levels, ...)
>            else {
>                panel.rect(0, 0.5, 1, 1, col = "#ccffcc",
>                           border = "transparent")
>                if (which.panel[1] == 2)
>                    panel.text(0, 0.75,
>                               labels = factor.levels[which.panel[2]])
>            }
>        })
>
> -Deepayan

______________________________________________
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. Received on Sat 12 Jul 2008 - 01:25:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Jul 2008 - 05:31:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive