[Rd] bug in plot.table(..., log='y')?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Sat May 28 18:23:37 CEST 2022


On 28/05/2022 11:33 a.m., Spencer Graves wrote:
> Dear R Developers:
> 
> 
> 	  Consider the following example:
> 
> 
> (tstTable <- table(rep(1:3, 3:1)))
> plot(tstTable)
> plot(tstTable, log='y')
> 
> 
> 	  "plot(tstTable)" works as expected.  "plot(tstTable, log='y')" gives
> a warning:
> 
> 
> Warning message:
> In plot.window(...) :
>     nonfinite axis=2 limits [GScale(-inf,0.477121,..); log=TRUE] --
> corrected now
> 
> 
> 	  AND the plot has a y axis scale running from 1e-307 to 1e+13.
> 
> 
> 	  This is with R 4.2.0 (R Console and the current RStudio) under macOS
> 11.6.6.
> 
> 
> 	  "plot(as.numeric(names(tstTable), as.numeric(tstTable), log='y'))"
> works as expected ;-)
> 
> 
> 	  Comments?
> 	  Thanks for your valuable work in making it easier for people
> everywhere to do quality statistics.

The help page ?plot.table says that ylim defaults to c(0, max(x)), i.e. 
c(0,3) in your example.  If you're asking to plot that on a log scale, 
there are bound to be problems.

If you specify ylim, e.g. as c(min(tstTable), max(tstTable)), things are 
fine in your example; they won't be in examples where the min is zero.

Duncan Murdoch



More information about the R-devel mailing list