ggtree
ggtree copied to clipboard
geom_treescale and layout="fan"
trafficstars
geom_treescale interacts oddly with the fan layout:
- If you give x and y they are actually interpreted as r and theta (polar coordinates)
- The units for y are are not degrees, radians or anything else standard, but based on the number of tips in the tree (i.e. 1 point of y is 360/n degrees where the tree has n tips)
- The scale line rotates as y changes. The above two points are manageable, but this means tinkering with a vector graphics package is basically essential if you want to place the scale
MWE:
library(ape)
library(ggtree)
a.tree <- rtree(100)
# small and large x values scale the tree
ggtree(a.tree, layout='fan') + geom_treescale(x = -50)
ggtree(a.tree, layout='fan') + geom_treescale(x = 50)
# y values rotate the line
ggtree(a.tree, layout='fan') + geom_treescale(x = 7, y = 15)
I was going to open the same issue for layout = "circular". It would be great to be able to position the scale in cartesian coordinates and be able to the bar horizontal.
it would be OK if y = 0.
If one is happy to have the scale to the right of the plot, sure. I'd like it below.
coord_radar seems to be a solution to this.
I don't have time to explore the details and this feature is not in high priority.
If you can work it out, PR is welcome.