[R] R: plotting values on graphics

Friedrich Leisch Friedrich.Leisch at ci.tuwien.ac.at
Fri Oct 6 15:10:07 CEST 2000

>>>>> On Fri, 6 Oct 2000 08:51:47 -0400,
>>>>> joseph d hughes (jdh) wrote:

jdh> Everyone,
jdh> I have an array of integer values which are located on a uniform 2-D grid.  I want to plot the integer values at the node locations. The closest I have come is with the following code:

jdh> for (i in 1:ny) {
jdh>   for (j in 1:nx) {
jdh>   ncell <- nx*(i - 1) + j
jdh>   ch <- as.character(ncount[ncell])
jdh>   tx <- j*dx - dx/2
jdh>   ty <- ny*dy - (i-1)*dy - dy/2
jdh>   points(tx, ty, pch = ch, col = "red", bg = "yellow", cex = 3)
jdh>   }
jdh> }

jdh> The problem with the code above is I only get a one character symbol at each node (e.g. n=123 gives me 1 on the screen).  Is there something wrong with my as.character or points function calls?  Is there a better way to do this?

The function text() allows plotting arbitrary strings at a give
(x,y)-position (with control over font, alignment, ...).

Hope this helps,

                        Friedrich  Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071      Friedrich.Leisch at ci.tuwien.ac.at
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch
     PGP public key http://www.ci.tuwien.ac.at/~leisch/pgp.key

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list