[R] writing text on graphics' window

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Tue Mar 23 21:13:53 CET 2004


Another approach is to use the textplot() function and friends from the
gregmisc library.  From ?textplot:

textplot              package:gregmisc              R Documentation

Display text information in a graphics plot.

Description:

     This function displays text output in a graphics window.  It is
     the equivalent of 'print' except that the output is displayed as a
     plot.

-Greg


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Paul Murrell
> Sent: Monday, March 22, 2004 7:46 PM
> To: sam.kemp2 at ntlworld.com
> Cc: r-help at stat.math.ethz.ch; dmurdoch at pair.com; Ray Brownrigg
> Subject: Re: [R] writing text on graphics' window
> 
> 
> Hi
> 
> 
> Ray Brownrigg wrote:
> >>From: Duncan Murdoch <dmurdoch at pair.com>
> >>Date: Sun, 21 Mar 2004 06:58:03 -0500
> >>
> >>On Sun, 21 Mar 2004 11:07:01 +0000, you 
> [sam.kemp2 at ntlworld.com] wrote:
> >>
> >>
> >>>Does anyone know of a method for writing text to the 
> graphics window, 
> >>>where there is *no* plot? Basically, I have developed a 
> 'significance 
> >>>test' and I would like the output on the graphics window to say 
> >>>something about the input parameters and the stats of the 
> significance test.
> >>
> >>You need to make sure a graphics device is active and establish a
> >>coordinate system there.  The easiest way to do that is to 
> make a call
> >>to plot() with everything turned off:
> >>
> >> plot(0:100,0:100,type='n',axes=FALSE,xlab="",ylab="")
> >>
> >>You may also want to reduce the "margins" if you want your output to
> >>take up the full frame, e.g.
> >>
> >> oldmargins <- par(mar=c(0,0,0,0))
> >> plot(0:100,0:100,type='n',axes=FALSE,xlab="",ylab="")
> >>
> > 
> > An easier way to activate a graphics device and establish a 
> coordinate
> > system is to call plot.new().
> > 
> > 
> > Try:
> > 
> >>plot.new()
> >>text(0, 0, "ABC")
> >>par("usr")
> > 
> > [1] -0.04  1.04 -0.04  1.04
> 
> 
> The grid package gives you the whole page to play with by default and 
> gives you more flexibility in how you place the text.  Try ...
> 
> library(grid)
> grid.text("Here's some\ntext", x=unit(1, "cm"),
>            y=unit(1, "npc") - unit(1, "cm"),
>            just=c("left", "top"))
> 
> Paul
> -- 
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> paul at stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html


LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}




More information about the R-help mailing list