Browse code

add title_gap in Legend()

Zuguang Gu authored on 25/04/2019 17:31:14
Showing3 changed files

... ...
@@ -1,8 +1,8 @@
1 1
 Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Make Complex Heatmaps
4
-Version: 1.99.7
5
-Date: 2019-03-15
4
+Version: 1.99.8
5
+Date: 2019-04-25
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
8 8
 Depends: R (>= 3.1.2), methods, grid, graphics, stats, grDevices
... ...
@@ -1,3 +1,9 @@
1
+CHANGES in VERSION 1.99.8
2
+
3
+* add `title_gap` in `Legend()
4
+
5
+========================
6
+
1 7
 CHANGES in VERSION 1.99.7
2 8
 
3 9
 * `UpSet()` supports adding complement sets.
... ...
@@ -73,6 +73,7 @@ Legends = function(...) {
73 73
 # -title_position Position of title relative to the legend. ``topleft``, ``topcenter``, ``leftcenter-rot``
74 74
 #     and ``lefttop-rot`` are only for vertical legend and ``leftcenter``, ``lefttop`` are only for 
75 75
 #     horizontal legend.
76
+# -title_gap Gap between title and the legend body.
76 77
 #
77 78
 # == details
78 79
 # Most of the argument can also be set in ``heatmap_legend_param`` argument in `Heatmap` or ``annotation_legend_param``
... ...
@@ -107,7 +108,8 @@ Legend = function(at, labels = at, col_fun, nrow = NULL, ncol = 1, by_row = FALS
107 108
 	legend_height = NULL, legend_width = NULL,
108 109
 	direction = c("vertical", "horizontal"),
109 110
 	title = "", title_gp = gpar(fontsize = 10, fontface = "bold"),
110
-	title_position = c("topleft", "topcenter", "leftcenter", "lefttop", "leftcenter-rot", "lefttop-rot")) {
111
+	title_position = c("topleft", "topcenter", "leftcenter", "lefttop", "leftcenter-rot", "lefttop-rot"),
112
+	title_gap = unit(1.5, "mm")) {
111 113
 
112 114
 	dev.null()
113 115
 	on.exit(dev.off2())
... ...
@@ -123,7 +125,7 @@ Legend = function(at, labels = at, col_fun, nrow = NULL, ncol = 1, by_row = FALS
123 125
 	# odevlist = dev.list()
124 126
 	direction = match.arg(direction)[1]
125 127
 	title_position = match.arg(title_position)[1]
126
-	title_padding = unit(1.5, "mm")
128
+	title_padding = title_gap
127 129
 	if(missing(col_fun)) {
128 130
 		if(is.null(border)) border = "white"
129 131
 		legend_body = discrete_legend_body(at = at, labels = labels, nrow = nrow, ncol = ncol,