[R] Positioning in xyplot

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Wed Apr 11 21:14:51 CEST 2007



Michael Kubovy said the following on 4/10/2007 5:54 PM:
> On Apr 10, 2007, at 7:07 PM, Deepayan Sarkar wrote:
> 
>> On 4/10/07, Michael Kubovy <kubovy at virginia.edu> wrote:
>>> Dear R-helpers,
>>>
>>> I have an xyplot
>>>
>>> of the following kind:
>>> xYplot(y ~ x | p, groups = factor(gg, levels = c('1', '5', '2', '4',
>>> '3')),
>>>         strip = strip.custom(var.name = 'g', factor.levels = c(1',  
>>> '5', '2',
>>> '4', '3'),
>>>                 strip.levels = T, strip.names = T, sep = ' = ',  
>>> shingle.intervals =
>>> NULL),
>>>         data = df, type = 'b', label.curves = F, layout = c(2, 3),
>>>         )
>>>
>>> Currently this puts the panels as follows
>>>
>>> 3
>>> 2  4
>>> 1  5
>>>
>>> I need:
>>>
>>>    3
>>> 2   4
>>> 1   5
>>>
>>> How can I do this? Any help will be much appreciated.
>> I don't understand what you mean. If you meant this:
>>
>>
>>    +---+
>>    |   |
>> +---+---+
>> |   |   |
>> +---+---+
>> |   |   |
>> +---+---+
>>
>> then see Sundar's answer. If you meant this:
>>
>>  +---+
>>  |   |
>> +-+---+-+
>> |   |   |
>> +---+---+
>> |   |   |
>> +---+---+
>>
>> then you are out of luck (unless you are willing to do some low  
>> level coding).
> 
> I guess I'm out of luck (I understood your two figures after turning  
> them into fixed width font). At least you put me out of *this*  
> misery. Thanks so much,
> 
> Michael
> _____________________________
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
> Parcels:    Room 102        Gilmer Hall
>          McCormick Road    Charlottesville, VA 22903
> Office:    B011    +1-434-982-4729
> Lab:        B019    +1-434-982-4751
> Fax:        +1-434-982-4766
> WWW:    http://www.people.virginia.edu/~mk9y/
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.


Seems like you may get a workaround (albeit kludgey) by using 
?print.trellis. Here's another example:

library(lattice)
z <- expand.grid(x = 1:10, p = 1:5, r = 1:10)
z$y <- rnorm(nrow(z))
z$p <- factor(z$p, levels = c(1, 5, 2, 4, 3))
bot <- xyplot(y ~ x | p, z, groups = r,
               layout = c(2, 2), type = "l",
               scales = list(alternating = 1),
               subset = p != 3)
top <- xyplot(y ~ x | p, z, groups = r,
               type = "l", xlab = "",
               scales = list(alternating = 2),
               subset = p == 3)

print(bot, c(0, 0, 1, 11/16))
print(top, c(1/5, 7/12, 4/5, 1), newpage = FALSE)

--sundar



More information about the R-help mailing list