Browse code

solve overlapping branches

git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@106654 bc3139a8-67e5-0310-9ffc-ced21a209358

g.yu authored on 22/07/2015 10:18:36
Showing 3 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ggtree
2 2
 Type: Package
3 3
 Title: a phylogenetic tree viewer for different types of tree annotations
4
-Version: 1.1.9
4
+Version: 1.1.10
5 5
 Author: Guangchuang Yu and Tommy Tsan-Yuk Lam
6 6
 Maintainer: Guangchuang Yu <guangchuangyu@gmail.com>
7 7
 Description: ggtree extends the ggplot2 plotting system which implemented the
... ...
@@ -1,3 +1,10 @@
1
+CHANGES IN VERSION 1.1.10
2
+------------------------
3
+ o solve overlapping branches for layout = "fan" || "radial",
4
+   that are coord_polar-ized layouts.
5
+   see https://github.com/GuangchuangYu/ggtree/issues/6,
6
+   contributed by Vincent Bonhomme. <2015-07-22, Wed>
7
+
1 8
 CHANGES IN VERSION 1.1.9
2 9
 ------------------------
3 10
  o update add_legend to align legend text <2015-07-06, Mon>
... ...
@@ -17,6 +17,7 @@
17 17
 ##' @importFrom ggplot2 ylab
18 18
 ##' @importFrom ggplot2 annotate
19 19
 ##' @importFrom ggplot2 scale_x_reverse
20
+##' @importFrom ggplot2 scale_y_continuous
20 21
 ##' @importFrom ggplot2 coord_flip
21 22
 ##' @importFrom ggplot2 coord_polar
22 23
 ##' @export
... ...
@@ -59,6 +60,8 @@ ggtree <- function(tr,
59 60
         p <- p + scale_x_reverse() + coord_flip()
60 61
     } else if (type == "fan" || type == "radial") {
61 62
         p <- p + coord_polar(theta = "y")
63
+        ## refer to: https://github.com/GuangchuangYu/ggtree/issues/6
64
+        p <- p + scale_y_continuous(limits=c(0, max(p$data$y)))
62 65
     } 
63 66
     
64 67
     if (showDistance == FALSE) {
... ...
@@ -97,13 +100,13 @@ geom_tree <- function(layout="phylogram", color="black", linetype="solid", size=
97 100
     lineend  = "round"
98 101
     if (layout == "phylogram" || layout == "fan") {
99 102
         if (length(color) != 1) {
100
-            color <- c(color, color)
103
+            color <- rep(color, 2) ## c(color, color)
101 104
         }
102 105
         if (length(linetype) != 1) {
103
-            linetype <- c(linetype, linetype)
106
+            linetype <- rep(linetype, 2) ## c(linetype, linetype)
104 107
         }
105 108
         if (length(size) != 1) {
106
-            size <- c(size, size)
109
+            size <- rep(size, 2) ## c(size, size)
107 110
         }
108 111
         geom_segment(aes(x    = c(x[parent], x[parent]),
109 112
                          xend = c(x,         x[parent]),