<p><em>Answer from @haci, converted from comment:</em></p>
<p>You can use the <code>pch</code> parameter in <code>anno_simple()</code> but you can only use a single character or a digit. It is not limited to symbols only,  you can provide a vector to <code>pch</code>, but only the first character would be printed. If by chance your values are [0-9] you can use <code>pch</code> as kind of hack for your purposes above.</p>

CC BY-SA 4.0
2021-07-14T11:45:52.277Z
2021-07-14T11:45:52.277Z
gringer
<p>I am trying to use ComplexHeatmap to plot heatmap with annotation. 
The code that I  have tried </p>

<pre><code>library(ComplexHeatmap)
library(circlize)

set.seed(123)
mat = matrix(rnorm(25), 5)
rownames(mat) = paste0("R", 1:5)
colnames(mat) = paste0("C", 1:5)

col_fun = colorRamp2(c(0, 2, 5), c("white", "blue", "red"))
data_foo = c(0.1, 3, 1.6, 2.8, 4)

ha = HeatmapAnnotation(which = "row", foo = data_foo, col = list(foo = col_fun))
Heatmap(mat, name = "mat", right_annotation = ha)

ha1 = HeatmapAnnotation(which = "row", foo = anno_text(data_foo))
Heatmap(mat, name = "mat", right_annotation = ha1)

</code></pre>

<p>Can I obtain the annotation with colors varying as per the annotation values and also display the values in the annotation? i.e is it possible to combine the annotation in both figures?
<a href="https://i.sstatic.net/y1DSx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/y1DSx.png" alt="HeatMap with color annotation"></a></p>

<p><a href="https://i.sstatic.net/0qBYQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0qBYQ.png" alt="HeatMap with values as annotation"></a></p>

<r><heatmap>
Heatmap annotation with value and colour gradient
# Heatmap annotation with value and colour gradient

(Asked by: username_0 on 2020-01-15)

I am trying to use ComplexHeatmap to plot heatmap with annotation. 
The code that I  have tried 
library(ComplexHeatmap)
library(circlize)

set.seed(123)
mat = matrix(rnorm(25), 5)
rownames(mat) = paste0("R", 1:5)
colnames(mat) = paste0("C", 1:5)

col_fun = colorRamp2(c(0, 2, 5), c("white", "blue", "red"))
data_foo = c(0.1, 3, 1.6, 2.8, 4)

ha = HeatmapAnnotation(which = "row", foo = data_foo, col = list(foo = col_fun))
Heatmap(mat, name = "mat", right_annotation = ha)

ha1 = HeatmapAnnotation(which = "row", foo = anno_text(data_foo))
Heatmap(mat, name = "mat", right_annotation = ha1)


Can I obtain the annotation with colors varying as per the annotation values and also display the values in the annotation? i.e is it possible to combine the annotation in both figures?

**Tags:** r, heatmap

---

## 1 answers

### Answer by username_1 on 2021-07-14. Score: 0

*Answer from @haci, converted from comment:*

You can use the `pch` parameter in `anno_simple()` but you can only use a single character or a digit. It is not limited to symbols only, you can provide a vector to `pch`, but only the first character would be printed. If by chance your values are [0-9] you can use `pch` as kind of hack for your purposes above.


---

