Woops.

Solution: pull development version of /phytools/ from GitHub.

    library(remotes)

    install_github("liamrevell/phytools")

That should fix it. (Not sure what got broken, but evidently I fixed it 
on GitHub & forgot about it.)

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 9/9/2025 9:53 AM, Joseph Brown wrote:
>
>       
> You don't often get email from [email protected]. Learn why this is 
> important <https://aka.ms/LearnAboutSenderIdentification>
>       
>
> CAUTION: EXTERNAL SENDER
> That code doesn't seem to work?
>
> Error in plot.xy(xy.coords(x, y), type = type, ...) : invalid line type
> 4.
> plot.xy(xy.coords(x, y), type = type, ...)
> 3.
> lines.default(a, b, col = colors[names(tree$maps[[i]])[j]], lwd = lwd,
> lty = lty[names(tree$maps[[i]])[j]], type = type)
> 2.
> lines(a, b, col = colors[names(tree$maps[[i]])[j]], lwd = lwd,
> lty = lty[names(tree$maps[[i]])[j]], type = type)
> 1.
> phenogram(mammal_cmap$tree, lnBodyMass, colors = mammal_cmap$cols,
> spread.cost = c(1, 0), fsize = 0.8, lwd = 3, ftype = "i")
>
> My info:
> R version 4.3.3 (2024-02-29)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 24.04.3 LTS
>
> other attached packages:
> [1] phytools_2.4-4 maps_3.4.3     ape_5.8-1
>
> JWB
>
> On Tue, Sep 9, 2025 at 9:44 AM Liam J. Revell via R-sig-phylo 
> <[email protected]> wrote:
>
>     Hi Lindsey.
>
>     To be honest, I don't see a problem with your code -- unless your R
>     graphical device does not support lwd=1.25. (That's the only thing I
>     could think of without being able to reiterate your analysis &
>     debug it.)
>
>     Here's a fully worked example of the same type of plot that uses data
>     packaged with /phytools/.
>
>         library(phytools)
>         data("mammal.tree")
>         data("mammal.data")
>
>         lnBodyMass<-setNames(log(mammal.data$bodyMass),
>            rownames(mammal.data))
>
>         mammal_cmap<-contMap(mammal.tree,lnBodyMass,
>            plot=FALSE)
>
>         mammal_cmap<-setMap(mammal_cmap,hcl.colors(n=100))
>
>         plot(mammal_cmap) ## standard contMap plot
>
>         dev.off()
>
>         phenogram(mammal_cmap$tree,lnBodyMass,
>            colors=mammal_cmap$cols,
>            spread.cost=c(1,0),fsize=0.8,lwd=3,
>            ftype="i")
>
>     If this doesn't help you figure out what's going wrong, please
>     feel free
>     to send me your data & code (or, better yet, a saved R workspace) and
>     I'd be happy to troubleshoot it here.
>
>     Best wishes, Liam
>
>     Liam J. Revell
>     Professor of Biology, University of Massachusetts Boston
>     Web: http://faculty.umb.edu/liam.revell/
>     <http://faculty.umb.edu/liam.revell/>
>     Book: Phylogenetic Comparative Methods in R
>     <https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r
>     <https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r>>
>
>     (/Princeton University Press/, 2022)
>
>
>     On 9/9/2025 9:27 AM, Lindsey Dehaan wrote:
>     > [You don't often get email [email protected]. Learn why
>     this is important athttps://aka.ms/LearnAboutSenderIdentification
>     <http://aka.ms/LearnAboutSenderIdentification> ]
>     >
>     > CAUTION: EXTERNAL SENDER
>     >
>     > Hi all,
>     >
>     > I have a quick question that I think someone could answer for me
>     in a
>     > couple minutes rather than spend 2 hours of my day trying to
>     figure it out.
>     >
>     > I want to make a phenogram (or traitagram) showing the evolutionary
>     > trajectory of a trait of a group of fishes. While this would be
>     > sufficient enough for the figure, I think it would be neat to
>     map the color
>     > scheme of the continuous character produced by contMap() onto
>     the branches
>     > of the phenogram. However, I am running into an error and I am
>     not exactly
>     > sure how to fix it. The phenogram plots no problem, the contMap
>     plots no
>     > problem, but I am having trouble combining the two outputs. The
>     error I
>     > keep getting is "Error in plot.xy(xy.coords(x, y), type = type,
>     ...) :
>     > invalid line type"
>     >
>     > I have tried to tweak the code so many times to get around this
>     error but I
>     > am finally at a loss. I would appreciate any pointers or tips anyone
>     > could throw my way. My code is below and I am happy to share the
>     data if
>     > needed.
>     >
>     > Best,
>     > Lindsey
>     >
>     >> phenogram(locate_fossil_phy, fineness_ratio, fsize = 0.5, ftype
>     = "reg",
>     > xlab=NULL, ylab="log Fineness Ratio")
>     >
>     > #Create contMap of continuous trait
>     >> obj<-contMap(locate_fossil_phy,fineness_ratio,plot=TRUE, res=50)
>     >> plot(obj,legend=0.75*max(nodeHeights(locate_fossil_phy)),
>     >       fsize=c(0.2,.8), lwd=2, label.offset=2,
>     >       outline=FALSE, ftype="off", fsize=0.66)
>     >
>     > #Change Colors
>     >> obj <- setMap(obj, c("#0000FF","#6600CC", "#FF0000",
>     "#990000")) #Blue to
>     > Red
>     >
>     > # Plot phenogram with obj$colors
>     >
>     phenogram(obj$tree,fineness_ratio,colors=obj$cols,spread.labels=TRUE,
>     >  spread.cost=c(1,0),fsize=0.3,ftype="reg",lwd=1.25,
>     >           ylab="Fineness ratio", ylim=c(0,2.5))
>     >
>     >
>     >
>     > *Error in plot.xy(xy.coords(x, y), type = type, ...) : invalid
>     line type*
>     > *-- *
>     > Lindsey DeHaan
>     > Ph.D. Candidate
>     > Department of Earth and Environmental Sciences
>     > University of Michigan
>     >
>     >          [[alternative HTML version deleted]]
>     >
>     > _______________________________________________
>     > R-sig-phylo mailing list [email protected]
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>     <https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
>     > Searchable archive
>     athttp://www.mail-archive.com/[email protected]/
>     <http://www.mail-archive.com/[email protected]/>
>             [[alternative HTML version deleted]]
>
>     _______________________________________________
>     R-sig-phylo mailing list - [email protected]
>     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/[email protected]/
>     <http://www.mail-archive.com/[email protected]/>
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to