Error in plot.window(...) : need finite 'ylim' values

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in plot.window(...) : need finite 'ylim' values

Rich Shepard
   Please provide a pointer to the source of this problem so I can understand
why it occurred.

   The data frame is:

millc.tds.z
            MC-0.5 MC-1 MC-2 MC-30 MC-50
1994-01-20     NA   NA  429    NA    NA
1994-03-24     NA   NA  479    NA    NA
1994-04-21     NA   NA  456    NA    NA
1994-05-19     NA  193  336    NA    NA
1994-06-13     NA   NA  391    NA    NA
1994-07-25     NA   NA  381    NA    NA
1994-12-27     NA   NA  378    NA    NA
1995-03-23     NA  232   NA    NA    NA
1995-03-28     NA   NA  439    NA    NA
1995-06-23     NA  249  273    NA    NA
1995-07-28     NA  288  348    NA    NA
1996-03-26    304  282  292    NA    NA
1996-04-15     NA  340  320    NA    NA
1996-04-16     NA   NA   NA    NA    NA
1996-06-12     NA   NA   NA   328    NA
1996-06-18    320  300  330    NA    NA
1996-07-23    500  312  384    NA    NA
1996-08-22    545   NA   NA    NA    NA
1996-09-26    570   NA   NA    NA    NA
1996-10-28    518   NA   NA    NA    NA
1996-11-22    458   NA   NA    NA    NA
1997-03-28     NA  388   NA    NA    NA
1997-05-28     NA  356   NA    NA    NA
1997-07-30     NA  502   NA    NA    NA
1998-04-16     NA  335   NA    NA    NA
1998-09-21     NA  748   NA    NA    NA
1999-05-19     NA  448   NA    NA    NA
1999-09-01     NA  676   NA    NA    NA
2000-03-30     NA  526   NA    NA    NA
2000-05-31     NA  426   NA    NA    NA
2001-04-25     NA  300   NA    NA    NA
2002-05-30     NA  310   NA    NA    NA
2002-07-30     NA  560   NA    NA    NA
2002-10-31     NA  930   NA    NA    NA
2003-03-28     NA  840   NA    NA    NA
2003-05-29     NA  360   NA    NA    NA
2003-09-19     NA 1100   NA    NA    NA
2003-11-24     NA 1100   NA    NA    NA
2004-03-30     NA  440   NA    NA    NA
2004-04-22     NA  450   NA    NA    NA
2004-07-19     NA  630   NA    NA    NA
2004-11-23     NA  830   NA    NA    NA
2005-04-29     NA  350   NA    NA    NA
2005-05-31     NA  490   NA    NA    NA
2005-07-28     NA  937   NA    NA    NA
2005-11-22     NA 1070   NA    NA    NA
2006-03-23     NA  548   NA    NA    NA
2006-06-21     NA  464   NA    NA    NA
2006-11-15     NA 1020   NA    NA    NA
2007-03-20     NA  636   NA    NA    NA
2007-04-25     NA  346   NA    NA    NA
2008-03-25     NA  506   NA    NA    NA
2008-03-27     NA  475   NA    NA    NA
2008-06-26     NA  372  395    NA    NA
2008-07-30     NA  634   NA    NA    NA
2009-03-27     NA  475   NA    NA    NA
2009-04-29     NA  358  374    NA    NA
2009-05-27     NA  315  347    NA    NA
2009-08-19     NA  754   NA    NA    NA
2009-11-11     NA 1050   NA    NA    NA
2010-05-20     NA  280   NA    NA    NA
2010-08-12     NA  852   NA    NA    NA
2011-05-18     NA  410   NA    NA    NA

   The command I tried, and the results, are:

plot(millc.tds.z, main = 'Mill Creek TDS', xlab = 'Time')
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

   I have other data frames with columns of 'NA' that plot OK. I want to
understand what makes this one different.

TIA,

Rich

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error in plot.window(...) : need finite 'ylim' values

Michael Weylandt
My initial guess is because you don't have any complete cases: cf.
this behavior plot(c(NA, NA))

If that's not it, dput() your data so that it's useable by others.

Michael

On Thu, Jan 5, 2012 at 10:43 AM, Rich Shepard <[hidden email]> wrote:

>  Please provide a pointer to the source of this problem so I can understand
> why it occurred.
>
>  The data frame is:
>
> millc.tds.z
>           MC-0.5 MC-1 MC-2 MC-30 MC-50
> 1994-01-20     NA   NA  429    NA    NA
> 1994-03-24     NA   NA  479    NA    NA
> 1994-04-21     NA   NA  456    NA    NA
> 1994-05-19     NA  193  336    NA    NA
> 1994-06-13     NA   NA  391    NA    NA
> 1994-07-25     NA   NA  381    NA    NA
> 1994-12-27     NA   NA  378    NA    NA
> 1995-03-23     NA  232   NA    NA    NA
> 1995-03-28     NA   NA  439    NA    NA
> 1995-06-23     NA  249  273    NA    NA
> 1995-07-28     NA  288  348    NA    NA
> 1996-03-26    304  282  292    NA    NA
> 1996-04-15     NA  340  320    NA    NA
> 1996-04-16     NA   NA   NA    NA    NA
> 1996-06-12     NA   NA   NA   328    NA
> 1996-06-18    320  300  330    NA    NA
> 1996-07-23    500  312  384    NA    NA
> 1996-08-22    545   NA   NA    NA    NA
> 1996-09-26    570   NA   NA    NA    NA
> 1996-10-28    518   NA   NA    NA    NA
> 1996-11-22    458   NA   NA    NA    NA
> 1997-03-28     NA  388   NA    NA    NA
> 1997-05-28     NA  356   NA    NA    NA
> 1997-07-30     NA  502   NA    NA    NA
> 1998-04-16     NA  335   NA    NA    NA
> 1998-09-21     NA  748   NA    NA    NA
> 1999-05-19     NA  448   NA    NA    NA
> 1999-09-01     NA  676   NA    NA    NA
> 2000-03-30     NA  526   NA    NA    NA
> 2000-05-31     NA  426   NA    NA    NA
> 2001-04-25     NA  300   NA    NA    NA
> 2002-05-30     NA  310   NA    NA    NA
> 2002-07-30     NA  560   NA    NA    NA
> 2002-10-31     NA  930   NA    NA    NA
> 2003-03-28     NA  840   NA    NA    NA
> 2003-05-29     NA  360   NA    NA    NA
> 2003-09-19     NA 1100   NA    NA    NA
> 2003-11-24     NA 1100   NA    NA    NA
> 2004-03-30     NA  440   NA    NA    NA
> 2004-04-22     NA  450   NA    NA    NA
> 2004-07-19     NA  630   NA    NA    NA
> 2004-11-23     NA  830   NA    NA    NA
> 2005-04-29     NA  350   NA    NA    NA
> 2005-05-31     NA  490   NA    NA    NA
> 2005-07-28     NA  937   NA    NA    NA
> 2005-11-22     NA 1070   NA    NA    NA
> 2006-03-23     NA  548   NA    NA    NA
> 2006-06-21     NA  464   NA    NA    NA
> 2006-11-15     NA 1020   NA    NA    NA
> 2007-03-20     NA  636   NA    NA    NA
> 2007-04-25     NA  346   NA    NA    NA
> 2008-03-25     NA  506   NA    NA    NA
> 2008-03-27     NA  475   NA    NA    NA
> 2008-06-26     NA  372  395    NA    NA
> 2008-07-30     NA  634   NA    NA    NA
> 2009-03-27     NA  475   NA    NA    NA
> 2009-04-29     NA  358  374    NA    NA
> 2009-05-27     NA  315  347    NA    NA
> 2009-08-19     NA  754   NA    NA    NA
> 2009-11-11     NA 1050   NA    NA    NA
> 2010-05-20     NA  280   NA    NA    NA
> 2010-08-12     NA  852   NA    NA    NA
> 2011-05-18     NA  410   NA    NA    NA
>
>  The command I tried, and the results, are:
>
> plot(millc.tds.z, main = 'Mill Creek TDS', xlab = 'Time')
> Error in plot.window(...) : need finite 'ylim' values
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
> 3: In min(x) : no non-missing arguments to min; returning Inf
> 4: In max(x) : no non-missing arguments to max; returning -Inf
>
>  I have other data frames with columns of 'NA' that plot OK. I want to
> understand what makes this one different.
>
> TIA,
>
> Rich
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error in plot.window(...) : need finite 'ylim' values

Rich Shepard
On Thu, 5 Jan 2012, R. Michael Weylandt wrote:

> My initial guess is because you don't have any complete cases: cf.
> this behavior plot(c(NA, NA))

Michael,

   Here's a data frame that does plot; no complete cases here, either:

mahalla.tds.z
            MAH-100 MAH-225 MAH-50 MASH-10 MASH-20 MASH-30 MASHSP-10
1996-03-27      NA     278     NA      NA      NA      NA        NA
1996-04-25     238     250     NA      NA      NA      NA        NA
1996-05-10     232      NA     NA      NA      NA      NA        NA
1996-05-23     226      NA     NA      NA      NA      NA        NA
1996-05-24      NA      NA     NA     136     216     258       162
1996-06-03     196     236     NA      NA      NA      NA        NA
1996-06-07     232      NA     NA      NA      NA      NA        NA
1996-07-18      NA      NA     NA      NA      NA      NA       224
1996-07-22     312      NA    294      NA      NA      NA        NA
1996-08-30     304      NA     NA      NA      NA      NA        NA
1996-09-26     387      NA     NA      NA      NA      NA        NA
1996-10-28     293      NA     NA      NA      NA      NA        NA

> If that's not it, dput() your data so that it's useable by others.

dput(millc.tds.z)
structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 304,
NA, NA, NA, 320, 500, 545, 570, 518, 458, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 193, NA, NA, NA, 232, NA, 249,
288, 282, 340, NA, NA, 300, 312, NA, NA, NA, NA, 388, 356, 502,
335, 748, 448, 676, 526, 426, 300, 310, 560, 930, 840, 360, 1100,
1100, 440, 450, 630, 830, 350, 490, 937, 1070, 548, 464, 1020,
636, 346, 506, 475, 372, 634, 475, 358, 315, 754, 1050, 280,
852, 410, 429, 479, 456, 336, 391, 381, 378, NA, 439, 273, 348,
292, 320, NA, NA, 330, 384, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 395, NA, NA, 374,
347, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 328, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA), .Dim = c(63L, 5L), .Dimnames = list(
     NULL, c("MC-0.5", "MC-1", "MC-2", "MC-30", "MC-50")), index =
structure(c(8785L,
8848L, 8876L, 8904L, 8929L, 8971L, 9126L, 9212L, 9217L, 9304L,
9339L, 9581L, 9601L, 9602L, 9659L, 9665L, 9700L, 9730L, 9765L,
9797L, 9822L, 9948L, 10009L, 10072L, 10332L, 10490L, 10730L,
10835L, 11046L, 11108L, 11437L, 11837L, 11898L, 11991L, 12139L,
12201L, 12314L, 12380L, 12507L, 12530L, 12618L, 12745L, 12902L,
12934L, 12992L, 13109L, 13230L, 13320L, 13467L, 13592L, 13628L,
13963L, 13965L, 14056L, 14090L, 14330L, 14363L, 14391L, 14475L,
14559L, 14749L, 14833L, 15112L), class = "Date"), class = "zoo")

Thanks,

Rich

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error in plot.window(...) : need finite 'ylim' values

Rich Shepard
In reply to this post by Michael Weylandt
On Thu, 5 Jan 2012, R. Michael Weylandt wrote:

> My initial guess is because you don't have any complete cases: cf.
> this behavior plot(c(NA, NA))

Michael,

   I may be creating the plots incorrectly: using plot() rather than
plot.zoo(). When I compare the plot of the zoo object to a lattice xyplot()
of points there are major discrepancies.

   Let me read more on plot.zoo() and try that before taking your time with
this.

Regards,

Rich

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error in plot.window(...) : need finite 'ylim' values

William Dunlap
Most plot methods die with an error like this
if all the values in y (or x) are NA.  E.g.,
you get the same problem with
   plot(rep(NA, 10))
Remove the columns that are all NA's before trying to
plot them.

It might be nice if the fancier plot methods could
trap such errors and perhaps put some text like
"(No Data)" where the plot should have been.

An ugly way of avoiding the error that stops you from
seeing the non-missing columns of the dataset is to
replace plot.window with a version that assigns an
arbitrary value to xlim or ylim if they contain illegal
values:

  > plot.window.orig <- plot.window
  > plot.window <- function(xlim, ylim, log="", asp=NA, ...) {
  +    if (!all(is.finite(xlim))) xlim <- c(0,1)
  +    if (!all(is.finite(ylim))) ylim <- c(0,1)
  +    plot.window.orig(xlim, ylim, log="", asp=NA, ...)
  + }
  > assignInNamespace("plot.window", plot.window, "graphics")

and then you can do things like
  d <- data.frame(one=1:10, two=rep(NA,10), three=sin(1:10))
  plot(d)
  library(zoo)
  plot(zoo(d))

(You should not call plot.zoo(yourData) since
plot(yourData) invokes plot.zoo if yourData is
a zoo object and plot.someOtherClass if it has
someOtherClass.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Rich Shepard
> Sent: Thursday, January 05, 2012 9:08 AM
> To: [hidden email]
> Subject: Re: [R] Error in plot.window(...) : need finite 'ylim' values
>
> On Thu, 5 Jan 2012, R. Michael Weylandt wrote:
>
> > My initial guess is because you don't have any complete cases: cf.
> > this behavior plot(c(NA, NA))
>
> Michael,
>
>    I may be creating the plots incorrectly: using plot() rather than
> plot.zoo(). When I compare the plot of the zoo object to a lattice xyplot()
> of points there are major discrepancies.
>
>    Let me read more on plot.zoo() and try that before taking your time with
> this.
>
> Regards,
>
> Rich
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Error in plot.window(...) : need finite 'ylim' values

Rich Shepard
On Thu, 5 Jan 2012, William Dunlap wrote:

> Most plot methods die with an error like this if all the values in y (or
> x) are NA.  E.g., you get the same problem with
>   plot(rep(NA, 10))
> Remove the columns that are all NA's before trying to plot them.

Bill,

   Ah, so. I did not look to see if all the data frames that did plot had at
least one value in each column.

> An ugly way of avoiding the error that stops you from seeing the
> non-missing columns of the dataset is to replace plot.window with a
> version that assigns an arbitrary value to xlim or ylim if they contain
> illegal values:

   Ugly is only skin deep; I'll take your advice on addressing this issue
with the two streams that fail to plot.

   There is still something I'm not doing properly because a lattice xyplot()
of TDS concentrations by time conditioned by sites on a stream show more
points than do the zoo line plots for the same stream. I assume that's not
correct. I need to look for the reason(s) for the differences, but I must
get a report revised and out to a client today so it will be at least
tomorrow before I'm back on this.

Thanks very much,

Rich

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.