pretty() sometimes isn't

David Brahm brahm@alum.mit.edu
Fri, 14 Jun 2002 14:04:43 -0400


Hi all,

R> seq(-.4, .8, length=7)
  [1] -4.000000e-01 -2.000000e-01  5.551115e-17  2.000000e-01  4.000000e-01
  [6]  6.000000e-01  8.000000e-01

Well that may not be a "bug", but it has this unfortunate consequence:

R> pretty(c(-.4,.8))
  [1] -4.000000e-01 -2.000000e-01  5.551115e-17  2.000000e-01  4.000000e-01
  [6]  6.000000e-01  8.000000e-01

And thus my plot axes look funny unless I apply zapsmall:
R> plot(c(-.4,.8), c(-.4,.8), axes=F)
R> axis(1, at=pretty(c(-.4,.8)))               # Yuck!
R> axis(2, at=zapsmall(pretty(c(-.4,.8))))     # Better!

So here's my simple suggestion: change the last line of pretty() from:
   seq(z$l, z$u, length = z$n + 1)
to:
   zapsmall(seq(z$l, z$u, length = z$n + 1))

I'm running R-1.5.0 on platform sparc-sun-solaris2.6.
-- 
                              -- David Brahm (brahm@alum.mit.edu)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._