[R] xyplot lattice fine control of axes limits and thick marks (with log scale)

David Winsemius dwinsemius at comcast.net
Wed Apr 11 15:16:22 CEST 2012


On Apr 11, 2012, at 9:03 AM, David Winsemius wrote:

>
> On Apr 11, 2012, at 6:28 AM, maxbre wrote:
>
>> hi, I just realised I want to go a little further in the control of  
>> the chart
>> appearance and I would like to have the same number of ticks  
>> displayed in
>> both axes of all panels
>>
>> given this code....
>>
>> xyplot(tv ~ ms | sub_family, data=tm,
>>     #as.table=TRUE,
>>     aspect="xy",
>>     xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
>>     ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
>>     scales= list(x=list(relation="free", log=10, cex=0.8),
>>                  y=list(relation="free", log=10, cex=0.8)),
>
> I'm wondering if you should be using relation="free" when you have  
> already set a panel specific range for the x and y limits? I'm  
> thinking that the panel function may be reversing your earlier  
> prepanel efforts. (No data offered  ... why don't you use one of the  
> many test datasets in the examples of the lattice package?)

On further meandering up this thread I see that you omitted the  
context of earlier data offerings, so not I in turn offer what I think  
is a your request. Change relation from "free" to "sliced"

scales= list(x=list(relation="sliced", log=10, cex=0.8, tick.number=5),
              y=list(relation="sliced", log=10, cex=0.8, tick.number=5))

-- 
David.


>
>
>>     prepanel = function(x, y, subscripts) {
>>       rr<- range(cbind(x,y))
>>       list(xlim = rr, ylim= rr)
>
>>     },
>>     panel = function(x, y ,subscripts,...) {
>>       panel.xyplot(x, y, cex=0.8,...)
>>       panel.abline(a = 0, b = 1, lty = 2, col ="gray")
>>       panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,  
>> pos=3,
>> offset=0.5, srt=0, adj=c(1,1))
>>     },
>> subscripts=TRUE,
>>     xscale.components = xscale.components.logpower,
>>     yscale.components = yscale.components.logpower
>>     )
>>
>> ...I have been trying to insert in the 'prepanel' and also in the  
>> 'panel'
>> the statement 'tick.number=5' but this does not seem to have any  
>> effect
>>
>> some useful hints for this?
>>
>> thanks a lot
>>
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list