[R] xyplot with 2 panels and 2 different x-scales

baptiste auguie baptiste.auguie at googlemail.com
Fri Jul 31 20:24:18 CEST 2009


Hi,

you want only the x scale to be free,

xyplot(place~rank|type, data=df1,
panel= function(x, y, ..., subscripts)
{
            panel.xyplot(x,y,..., subscripts)
            require(grid)
             panel.grid(h = -1,v = 0, lty="dotted")
             grid.text(unit(x,"native"),
                       unit(y,"native"),
                       label=x, just="center")

}, scales = list(x=list(relation="free")))


HTH,

baptiste

2009/7/31 taz9 <alienz747 at gmail.com>:
>
> I used the scales relation to obtain different x-scales for each panel.
> However, there's a gap between the 2 panels. Any ideas on how I could remove
> it?
>
> xyplot(place~rank|type, data=df1, scales=(relation="free"),
> panel= function(x, y, ..., subscripts) {
>             panel.xyplot(x,y,..., subscripts)
>             require(grid)
>              panel.grid(h = -1,v = 0, lty="dotted")
>              grid.text(unit(x,"native"),
>                        unit(y,"native"),
>                        label=x, just="center")
>
>              })
>
> http://www.nabble.com/file/p24760249/example2.png
>
>
>
> taz9 wrote:
>>
>> Hi All,
>>
>> I have this data:
>>
>> type<-c("country","country","country","world","world","world")
>> place<-c("A","B","C","A","B","C")
>> rank<-c(1,3,5,512,420,320)
>> df1<-data.frame(type,place,rank)
>>
>> and need to produce an xyplot with 2 panels, where the x-values are
>> labelled:
>>
>>
>> xyplot(place~rank|type, data=df1,
>> panel= function(x, y, ..., subscripts)
>> {
>>              panel.xyplot(x,y,..., subscripts)
>>              require(grid)
>>               panel.grid(h = -1,v = 0, lty="dotted")
>>               grid.text(unit(x,"native"),
>>                         unit(y,"native"),
>>                         label=x, just="center")
>>
>> })
>>
>> Now as you can see, the range of data is very different for the 2 panels.
>> I'd like to have the x-scales be different in each panel to better
>> visualize this data.
>>
>>  http://www.nabble.com/file/p24760060/example1.png
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/xyplot-with-2-panels-and-2-different-x-scales-tp24760060p24760249.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list