[R] lattice package: line end style
Peter Ehlers
ehlers at ucalgary.ca
Tue Apr 6 22:53:48 CEST 2010
On 2010-04-06 7:28, Daniel Alcock wrote:
> First, apologies for no example data but I don't think it's needed in
> this case,
>
> Q: Can (and if so how ) the line end style be changed for 'cloud' plots?
>
> I've tried par(lend=2), trellis.par.set(add.line = list(lend=2)) and
> much googling but to no avail
>
You can't use 'lend' because it's not an add.line component. What
you need is the grid graphics parameter 'lineend' which is
ultimately used in lsegments().
Here's a crude way to possible achieve what you need.
(I'm still getting to grips with grid graphics.)
This will replace panel.cloud and panel.3dscatter
with very minor modifications.
1. make a copy of panel.3dscatter
You should find, near the end, a call to lsegments() that
ends with:
lwd = lwd[ord])
replace that line with:
lwd = lwd[ord], ...)
This will permit passing grid graphics parameters to gpar() in
lsegments().
(I think that all we really need is for Deepayan to make this
change to panel.3dscatter; I suspect that this was an oversight,
but there may well be good reasons.)
2. Save your copy as mypanel.3dscatter and set its environment to
lattice's namespace:
environment(mypanel.3dscatter) <- environment(xyplot)
3. Make a copy of panel.cloud
Change the default argument for panel.3d.cloud from
"panel.3dscatter" to "mypanel.3dscatter" and save the
modified function to mypanel.cloud and set its environment
as above.
Now you should be able to call cloud:
cloud(z ~ x*y | etc, panel = "mypanel.cloud", lineend = "square")
Your choice are "round" (default), "butt" and "square".
-Peter Ehlers
> Thanks in advance
>
> Dan
>
> P.S. the reason for this is that the round end looks bad at lwd=3 or
> more
>
> Daniel Alcock
> Malaria Genetics (T112)
> Wellcome Trust Sanger Institute
> Cambridge
> CB10 1SA
> UK
> +44 (0)1223 834244 ext. 4994
> "The most exciting phrase to hear in science, the one that heralds new
> discoveries, is not Eureka! But rather, "hmm.... that's funny...." --
> Isaac Asimov
>
>
>
>
--
Peter Ehlers
University of Calgary
More information about the R-help
mailing list