Hi Rafael. When I load your workspace & run the following code I can produce the attached plot. Does this not work for you?

library(phytools)
dat<-dat[!is.na(dat)]
tips<-setdiff(tr$tip.label,names(dat))
tr<-drop.tip(tr,tips)
pdf(file="tree.pdf")
plotTree.wBars(tree=tr, x=dat, lwd=1, type='fan', scale=0.05,
        width=0.35, col='red')
dev.off()

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 11/11/2017 10:49 AM, Rafael S Marcondes wrote:
Hi Liam,

That did solve that problem and now a tree is plotted. But it is just a plain tree without bars at the tips. Here's what I'm doing and the error I get:

> plotTree.wBars(tree=tr, x=dat, type='fan', scale=0.05, width=1, col='red')
Error in if (min(x) < 0) h <- max(nodeHeights(tree)) :
   missing value where TRUE/FALSE needed

I thought the problem might be that some of my trait values are negative. But apparently that's not it, because dat=dat-min(dat) doesn't solve the problem.

Thanks,

*--
*
*Rafael Sobral Marcondes*
PhD Candidate (Systematics, Ecology and Evolution/Ornithology)

Museum of Natural Science <http://sites01.lsu.edu/wp/mns/>
Louisiana State University
119 Foster Hall
Baton Rouge, LA 70803, USA

Twitter: @rafmarcondes <https://twitter.com/rafmarcondes>


On Fri, Nov 10, 2017 at 7:06 PM, Liam J. Revell <liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>> wrote:

    Hi Rafael.

    It seems to just be that some of the values in your data vector are NAs.

    Try:

    dat<-dat[!is.na <http://is.na>(dat)]
    tr<-drop.tip(tr,setdiff(tr$tip.label,names(dat)))
    plotTree.wBars(tr,dat,type="fan",scale=0.1)

    and you should obtain something that makes sense.

    All the best, Liam

    Liam J. Revell, Associate Professor of Biology
    University of Massachusetts Boston
    web: http://faculty.umb.edu/liam.revell/
    <http://faculty.umb.edu/liam.revell/>
    email: liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
    blog: http://blog.phytools.org

    On 11/10/2017 6:04 PM, Rafael S Marcondes wrote:

        Hi Liam,

        Thanks for the quick reply. Playing with the scale argument
        didn't help. I have attached my script and environment.

        Thanks,

        *--
        *
        *Rafael Sobral Marcondes*
        PhD Candidate (Systematics, Ecology and Evolution/Ornithology)

        Museum of Natural Science <http://sites01.lsu.edu/wp/mns/
        <http://sites01.lsu.edu/wp/mns/>>
        Louisiana State University
        119 Foster Hall
        Baton Rouge, LA 70803, USA

        Twitter: @rafmarcondes <https://twitter.com/rafmarcondes
        <https://twitter.com/rafmarcondes>>


        On Fri, Nov 10, 2017 at 5:25 PM, Liam J. Revell
        <liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
        <mailto:liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>>> wrote:

             Hello Rafael.

             Have you tried adjusting the argument 'scale' which sets
        the factor
             by which x will be rescaled so that the tree & data can be
        plotted
             in the same space?

             Also, if you are just plotting a right-facing phylogram I
        recommend
             plotTree.barplot (also within phytools) which is in some
        ways more
             flexible & robust.

             Failing any of these options you are welcome to send me
        your saved
             workspace so I can investigate (& if there is a bug in
        phytools -
             fix it).

             All the best, Liam

             Liam J. Revell, Associate Professor of Biology
             University of Massachusetts Boston
             web: http://faculty.umb.edu/liam.revell/
        <http://faculty.umb.edu/liam.revell/>
             <http://faculty.umb.edu/liam.revell/
        <http://faculty.umb.edu/liam.revell/>>
             email: liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
        <mailto:liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>>

             blog: http://blog.phytools.org

             On 11/10/2017 4:55 PM, Rafael S Marcondes wrote:

                 Hi all,

                 I'm encountering a little bump trying to use this
        really cool
                 plot function
                 in phytools and I can't figure out what's wrong:

                     plotTree.wBars(tree=tr, x=dat)

                 Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
                 need finite 'xlim' values

                 Including an xlim argument doesn't work:

                     plotTree.wBars(tree=tr, x=dat, xlim=c(0,100),
        ylim=c(0,100))

                 Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
                 need finite 'xlim' values

                 Thanks for any help!


                 *--*
                 *Rafael Sobral Marcondes*
                 PhD Candidate (Systematics, Ecology and
        Evolution/Ornithology)

                 Museum of Natural Science
        <http://sites01.lsu.edu/wp/mns/ <http://sites01.lsu.edu/wp/mns/>
                 <http://sites01.lsu.edu/wp/mns/
        <http://sites01.lsu.edu/wp/mns/>>>
                 Louisiana State University
                 119 Foster Hall
                 Baton Rouge, LA 70803, USA

                 Twitter: @rafmarcondes
        <https://twitter.com/rafmarcondes <https://twitter.com/rafmarcondes>
                 <https://twitter.com/rafmarcondes
        <https://twitter.com/rafmarcondes>>>

                          [[alternative HTML version deleted]]

                 _______________________________________________
                 R-sig-phylo mailing list - R-sig-phylo@r-project.org
        <mailto:R-sig-phylo@r-project.org>
                 <mailto:R-sig-phylo@r-project.org
        <mailto:R-sig-phylo@r-project.org>>
        https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
        <https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
                 <https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
        <https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>>
                 Searchable archive at
        http://www.mail-archive.com/r-sig-phylo@r-project.org/
        <http://www.mail-archive.com/r-sig-phylo@r-project.org/>
                 <http://www.mail-archive.com/r-sig-phylo@r-project.org/
        <http://www.mail-archive.com/r-sig-phylo@r-project.org/>>



Attachment: tree.pdf
Description: Adobe PDF document

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to