[R] arrow plots
Deepayan Sarkar
deepayan.sarkar at gmail.com
Fri Dec 18 13:52:09 CET 2009
On Wed, Dec 9, 2009 at 10:08 AM, Cable, Samuel B Civ USAF AFMC
AFRL/RVBXI <Samuel.Cable at hanscom.af.mil> wrote:
> Thanks, all, for the help. Much obliged. I realize now that I should
> have said that I am using lattice graphics. The par() command has not
> been helpful in convincing lattice to plot outside of the default
> window. Any other advice is appreciated. Thanks again.
[Sorry for the late reply, I missed your mail the first time around.]
I think you need the 'legend' functionality. A naive example is:
arrowFun <- function(x = c(0.25, 0.75), ...)
{
require(grid)
linesGrob(x = x, y = 0.5, default.units = "npc",
arrow = arrow(...))
}
xyplot(1 ~ 1, legend = list(top = list(fun = arrowFun, args = list(x =
c(0.1, 0.5)))))
xyplot(1 ~ 1, legend = list(top = list(fun = arrowFun(type = "closed"))))
Your actual requirements would be more complicated because (1) your
grob will be more complicated (but see draw.key and draw.colorkey for
examples) and (2) your legend has to get resized in sync with the
plot. The second part is more complicated, and the simplest approach
would be to fix the absolute size of your panels (see ?print.trellis).
Of course the easiest solution would be to draw your arrow inside the
panel.
-Deepayan
More information about the R-help
mailing list