[R] arrow plots
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Dec 8 19:56:34 CET 2009
On Tue, 2009-12-08 at 13:42 -0500, Cable, Samuel B Civ USAF AFMC
AFRL/RVBXI wrote:
> Am doing some vector plots with the arrows() function. Works well. But
> what I need to do is supply an arrow for scaling for the reader. I need
> to plot an arrow of some known magnitude somewhere on the page
> (preferably outside the bounds of the plot, so that it can be seen
> clearly) with some text underneath it that says, for instance, "10
> kg-m/sec". Any ideas? Thanks.
You can plot outside the plotting region using the 'xpd' plotting
parameter:
plot(1:10, 1:10) ## dummy plot
op <- par(xpd = TRUE) ## change clipping parameter & save defaults
arrows(9, 10.75, 10, 10.75, length = 0.1) ## draw reference arrow
text(9.5, 11,
labels = expression(10 ~ kg ~ m ~ sec^{"-1"})) ## add key
par(op) ## reset plotting parameter defaults
You'll probably need to tweak the expression to get the units you
wanted.
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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