ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

"gradient" in geom_hilight does not work properly with coord_flip() or layout_dendrogram()

Open PandengWang opened this issue 1 year ago • 0 comments
trafficstars

Prerequisites

  • [x] Have you read Feedback and follow the guide?
    • [x] make sure you are using the latest release version
    • [x] read the documents
    • [x] Google your question/issue

Describe your issue

  • [x] Make a reproducible example (e.g. 1)
  • [x] your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Ask in right place

  • [x] for bugs or feature requests, post here (github issue)
  • [x] for questions, please post to google group

Thanks so much for developing such a useful package!

The gradient.direction does not work properly when using dendrogram layout. Please see the following example:

tre <- rtree(5)
ggtree(tre) + 
  layout_dendrogram() +
  geom_tiplab(hjust = 0.5, align = T, vjust = 0)  +
  geom_hilight(
         mapping=aes(subset = node %in% 1:5,
                     node = node,
                     fill = label,
                     alpha = 1
                     ),
         type = "gradient",
         to.bottom = T,
         align = "both",
         show.legend = F
     )

or 

ggtree(tre) + 
  geom_tiplab(hjust = 0.5, align = T, vjust = 0)  +
  geom_hilight(
         mapping=aes(subset = node %in% 1:5,
                     node = node,
                     fill = label,
                     alpha = 1
                     ),
         type = "gradient",
         to.bottom = T,
         align = "both",
         show.legend = F
     ) + 
  coord_flip()

Is there a solution to this issue?

Thanks!

PandengWang avatar Sep 12 '24 10:09 PandengWang