Browse code

Commit made by the Bioconductor Git-SVN bridge.

Commit id: c9281723f26ce3b7e303fde5643c5daf6a8ddaac

o update add_legend <2015-05-21, Thu>



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

g.yu authored on 21/05/2015 09:54:04
Showing 2 changed files

  • NEWS index bb7ac9d..5b3db1a 100644
  • R/ggtree.R index c2c0770..e1a5976 100644
... ...
@@ -1,6 +1,6 @@
1 1
 CHANGES IN VERSION 1.1.6
2 2
 ------------------------
3
- o update add_colorbar <2015-05-21, Thu>
3
+ o update add_colorbar & add_legend <2015-05-21, Thu>
4 4
  o add example of add_legend and gheatmap in vignette <2015-05-18, Mon> 
5 5
  o gheatmap implementation of gplot <2015-05-18, Mon>
6 6
  o add_legend for adding evolution distance legend <2015-05-18, Mon>
... ...
@@ -527,6 +527,8 @@ add_legend <- function(p, x=NULL, y=NULL, offset=NULL, font.size=4, ...) {
527 527
         offset <- offset / 100
528 528
     }
529 529
     p <- p + geom_segment(x=x, y=y, xend=x+d, yend=y, ...) +
530
-        geom_text(x=x+d/2, y=y+offset, label=d, size=font.size, ...)
530
+        geom_text(x=x+d/2, y=y-offset, label=d, size=font.size, ...) +
531
+            geom_segment(x=x, y=y-offset/2, xend=x, yend=y+offset/2, ...) +
532
+                geom_segment(x=x+d, y=y-offset/2, xend=x+d, yend=y+offset/2, ...)
531 533
     return(p)
532 534
 }