YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
821 stars 172 forks source link

geom_hilight rectangle unreasonably long #605

Open ETaSky opened 5 months ago

ETaSky commented 5 months ago

Prerequisites

Ask in right place

Problem description

First of all, thanks for the excellent package. I am reporting a tiny issue that may be quite easy to be fixed. As shown in the following graph using geom_hilight (since it is obvious, I did not attach the tree). p + theme_tree2() + geom_hilight(p$data %>% filter(isTip), to.bottom = T , aes(node = node), type = "rect") example

the length of the hilight bar on x-axis is too long for some occasions (as highlighted by the red lines), both extend and extendto are not able to gracefully handle this situation because it is due to the branch length is too long and the xmax of that tip seems directly related to the branch length according to line 444-455

https://github.com/YuLab-SMU/ggtree/blob/38016ab1e3fde1ff88ec131e2e6e89aa4a234d9d/R/geom_hilight.R#L444

I think it would be nicer that remove the branch length depended behaviour, and control the length just use extend (with a default value) and extendto. I don't know how to make modifications to the functions so it would be great if you can help with the issue.

Thanks!