Richard Vlasimsky
2011-Jan-12 00:01 UTC
[R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values"
Has anyone successfully created a PNG file for a dendrogram? I am able to successfully launch and view a dendrogram in Quartz. However, the dendrogram is quite large (too large to read on a computer screen), so I am trying to save it to a file (1000x4000 pixels) for viewing in other apps. However, whenever I try to initiate a PNG device, I get a "need finitite 'xlim' values" error. Here is some example code to illustrate my point: cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); distance <- as.dist(1.0-cor.matrix); hc <- hclust(distance); p <- plot(hc); plot(p); #This works! Plot is generated in quartz no problem. #Now, try this: png(filename="delme.png",width=4000,height=1000); cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); distance <- as.dist(1.0-cor.matrix); hc <- hclust(distance); p <- plot(hc); plot(p); #Error in plot.window(...) : need finite 'xlim' 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 This is the exact same code, only a prior call to png() causes the seemingly unrelated xlim to fail. Why is this? Thanks, Richard Vlasimsky
Peter Langfelder
2011-Jan-12 00:15 UTC
[R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values"
I'm guessing that your code actually generates two plots, one with the command p <- plot(hc) and one with plot(p), which doesn't work for a png. Try getting rid of the plot(p). Peter On Tue, Jan 11, 2011 at 4:01 PM, Richard Vlasimsky <richard.vlasimsky at imidex.com> wrote:> > Has anyone successfully created a PNG file for a dendrogram? > > I am able to successfully launch and view a dendrogram in Quartz. ?However, the dendrogram is quite large (too large to read on a computer screen), so I am trying to save it to a file (1000x4000 pixels) for viewing in other apps. ?However, whenever I try to initiate a PNG device, I get a "need finitite 'xlim' values" error. > > > > Here is some example code to illustrate my point: > > cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); > distance <- as.dist(1.0-cor.matrix); > hc <- hclust(distance); > p <- plot(hc); > plot(p); > #This works! ?Plot is generated in quartz no problem. > > > #Now, try this: > png(filename="delme.png",width=4000,height=1000); > cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); > distance <- as.dist(1.0-cor.matrix); > hc <- hclust(distance); > p <- plot(hc); > plot(p); > #Error in plot.window(...) : need finite 'xlim' 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 > > This is the exact same code, only a prior call to png() causes the seemingly unrelated xlim to fail. ?Why is this? > > Thanks, > Richard Vlasimsky > ______________________________________________ > R-help at r-project.org 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. >
Bill.Venables at csiro.au
2011-Jan-12 00:35 UTC
[R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values"
I very much doubt your first example does work. the value of plot() is NULL which if you plot again will give the error message you see in your second example. What where you trying to achieve doing p <- plot(hc) plot(p) ### this one is trying to plot NULL ? Here is an example (such as you might have given, according to the posting guide):> x <- matrix(rnorm(500*5), 500, 5) > dc <- as.dist(1-cor(x)) > hc <- hclust(dc) > p <- plot(hc) > plot(p)Error in plot.window(...) : need finite 'xlim' 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>Look familiar? This is why:> pNULL>-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Richard Vlasimsky Sent: Wednesday, 12 January 2011 10:01 AM To: r-help at r-project.org Subject: [R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values" Has anyone successfully created a PNG file for a dendrogram? I am able to successfully launch and view a dendrogram in Quartz. However, the dendrogram is quite large (too large to read on a computer screen), so I am trying to save it to a file (1000x4000 pixels) for viewing in other apps. However, whenever I try to initiate a PNG device, I get a "need finitite 'xlim' values" error. Here is some example code to illustrate my point: cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); distance <- as.dist(1.0-cor.matrix); hc <- hclust(distance); p <- plot(hc); plot(p); #This works! Plot is generated in quartz no problem. #Now, try this: png(filename="delme.png",width=4000,height=1000); cor.matrix <- cor(mydata,method="pearson",use="pairwise.complete.obs"); distance <- as.dist(1.0-cor.matrix); hc <- hclust(distance); p <- plot(hc); plot(p); #Error in plot.window(...) : need finite 'xlim' 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 This is the exact same code, only a prior call to png() causes the seemingly unrelated xlim to fail. Why is this? Thanks, Richard Vlasimsky ______________________________________________ R-help at r-project.org 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.
David Winsemius
2011-Jan-12 02:27 UTC
[R] Problems creating a PNG file for a dendrogram: "Error in plot.window(...) : need finite 'xlim' values"
On Jan 11, 2011, at 7:01 PM, Richard Vlasimsky wrote:> > Has anyone successfully created a PNG file for a dendrogram? > > I am able to successfully launch and view a dendrogram in Quartz. > However, the dendrogram is quite large (too large to read on a > computer screen), so I am trying to save it to a file (1000x4000 > pixels) for viewing in other apps. However, whenever I try to > initiate a PNG device, I get a "need finitite 'xlim' values" error. > > > > Here is some example code to illustrate my point: > > cor.matrix <- > cor(mydata,method="pearson",use="pairwise.complete.obs"); > distance <- as.dist(1.0-cor.matrix); > hc <- hclust(distance); > p <- plot(hc); > plot(p); > #This works! Plot is generated in quartz no problem. > > > #Now, try this: > png(filename="delme.png",width=4000,height=1000); > cor.matrix <- > cor(mydata,method="pearson",use="pairwise.complete.obs"); > distance <- as.dist(1.0-cor.matrix); > hc <- hclust(distance); > p <- plot(hc); > plot(p); > #Error in plot.window(...) : need finite 'xlim' 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 -InfI'm not sure the other two answers address the problems I found. When I try to set up a png file with the parameters width=4000,height=1000, on a Mac I intially got no plot with what is an otherwise valid command. But after successfully getting plotting to a png device the logjam appear broken. Try: graphics.off() dev.list() #NULL png(filename="delme.png",width=4000,height=1000); plot(hc) dev.off() (Of course I used dev.off() which you did not, but even adding dev.off() was not enough to get success, at least initially. I don't understand the suggestion to get rid of plot(hc) or the suggestion that hclust() returns NULL. That's certainly not how I read the help page and examples for hclust.)> > This is the exact same code, only a prior call to png() causes the > seemingly unrelated xlim to fail. Why is this? > > Thanks, > Richard VlasimskyDavid Winsemius, MD West Hartford, CT