[R] Custom axis function in lattice:::xyplot
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed May 26 20:19:54 CEST 2010
<snip />
>
> # There must a better way, but this works; add
>
> labels = levels(dat$fac)[panel.number()],
>
> # to your panel.axis() call in axis.VarLabs.
Thanks Peter. I had tried that but it didn't work. Now just realised I
was hitting a scoping problem and that my example was subtly different
to the real world problem. In the real world situation I had
axis.VarLabs defined outside of the actual plotting function and the
xyplot call was being arranged by the plotting function. Hence I was
getting an error with the suggestion you sent along lines of
Error in levels(dat$fac) : object 'dat' not found
Moving axis.VarLabs to be defined locally within my plotting function
solves this problem and is goo enough for me.
So many thanks Peter; I've been banging my head on this one for a couple
of days now [although I have taken the opportunity to read a lot more of
Deepayan's excellent Lattice book whilst trying to sort this all out].
<snip />
> >
> > Secondly, how do you ensure there is enough space around the plot to
> > draw the axis labels without truncation - as can be seen on the example
> > xyplot.
>
> # Look at the settings for layout.heights, especially
> # axis.top and top.padding:
Will take a look at this and Deepayan's legend suggestion to see which
suits best.
Cheers,
All the best,
G
>
> xyplot(....,
> par.settings = list(layout.heights =
> list(axis.top = xxx,
> top.padding = xxx)))
>
> # (Shouldn't need both; I don't know which is more
> # suitable for you.)
>
> -Peter Ehlers
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list