Error in plot.window(xlim, ylim, log = log, ...) : need finite 'xlim' values
Closed this issue · 2 comments
Hi,
I want to produce a barplot next to a plotted tree. But the bars doesn't show.
Below is my code:
#library(phytools)
load data
myTree <- ape::read.tree('longname_sptree.newick.tree')
GeneCount <- read.csv('Sp_tree_counts.csv')
extract values.
keeps <- c("Counts")
Counts = GeneCount[keeps]
counts = setNames(Counts)
#Plot
plotTree.wBars(myTree,GeneCount$Counts, type = "phylogram",scale = 0.00001)
par(mar = c(5.1,4.1,4.1,2.1))
plotTree.barplot(myTree,exp(counts),args.plotTree = list(fsize = 0.5), args.barplot = list(xlab = "counts (mm)"))
And this is the error:
plotTree.barplot(myTree,exp(counts),args.plotTree = list(fsize = 0.5), args.barplot = list(xlab = "counts (mm)"))
Error in plot.window(xlim, ylim, log = log, ...) :
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
My figure is like this:
How can I change it? Is that the problem with my data file?
Thank you so much.
Regards,
Zoey
Dear @Zoey-Aminah.
It looks like the problem is the size of your plotting device (and/or the size of the plotting elements, such as the label text). To verify this, try plotting to a large PDF and see if that works. To accomplish this, one normally runs something like the following code:
pdf(file="Rplot.pdf",width=12,height=12)
plotTree.barplot(myTree,exp(counts),args.plotTree = list(fsize = 0.5), args.barplot = list(xlab = "counts (mm)"))
dev.off()
This creates a 12" x 12" PDF figure. You can increase those dimensions as necessary.
-- Liam