<p>This solution doesn't reproduce the plot, but it would do if the numerical ranges between the triangles do not overlap.</p>
<pre><code>import matplotlib.pyplot as plt
import seaborn as sns

xx = plt.get_cmap('rocket').copy()
xx.set_under('none')
yy = plt.get_cmap('mako').copy()
yy.set_over('none')
axis = sns.heatmap(dataframe, vmin=-1, cmap=xx, cbar_kws={'pad': -0.04})
sns.heatmap(dataframe, vmin=0, vmax=1, cmap=yy, ax=axis)
plt.show()
</code></pre>
<p>My colour schemes are not great but they are distinct, you can search for more here:
<a href="https://seaborn.pydata.org/tutorial/color_palettes.html" rel="nofollow noreferrer">https://seaborn.pydata.org/tutorial/color_palettes.html</a></p>
<p>The idea is this would address a situation where you compare the <em>r</em>-value OR a <em>p</em>-value against another set of values where are &gt; 1. That's what the <code>vmin</code> and <code>vmax</code> are doing.</p>
<p>This is a ONE np array or dataframe solution. In other words you will need to combine your data sets. The solution you want is a two dataframes in one heatmap square. You can put two triangles side-by-side, i.e. one dataframe per heatmap, but I don't know who to place two separate dataframes in one heatmap.</p>

CC BY-SA 4.0
2022-03-22T14:51:44.250Z
2022-03-22T17:17:22.953Z
2022-03-22T17:17:22.953Z
M__
<p>I'm looking to make a two, two range colour scheme heatmap where each range corresponds to a separate triangle in the heatmap square.</p>
<p>I am looking for a relevant guide for this heatmap. Any recommended package/library or guides? Thanks!</p>
<p><a href="https://i.sstatic.net/0qE8O.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0qE8O.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-03-22T13:19:00.203Z
Are you using R or Python, i.e. you need a Dataframe and its what language you are okay with? Secondly, are you fine doing a single colour heat map? For example even I know with ggplot2 this is easy if you're using uniform colour scheme?
M__
CC BY-SA 4.0
2022-03-22T13:20:43.617Z
I'm okay with both, but I prefer more on Python. It's okay if you want to show me the single colour heat map with ggplot2 (I'm okay with R).
raysteven
CC BY-SA 4.0
2022-03-22T17:01:41.437Z
If you're not married to this idea and just wish to show correlations and significance at the same time, R's corrplot can do this. It uses `*`, `**` etc. as content to show p-value thresholds, and a color scale to show correlation value.
Ram RS
<r><python><heatmap><complexheatmap>
Constructing Two Triangle Heatmaps in One Square
# Constructing Two Triangle Heatmaps in One Square

(Asked by: username_0 on 2022-03-22)

I'm looking to make a two, two range colour scheme heatmap where each range corresponds to a separate triangle in the heatmap square.

I am looking for a relevant guide for this heatmap. Any recommended package/library or guides? Thanks!

[![enter image description here](https://i.sstatic.net/0qE8O.png)](https://i.sstatic.net/0qE8O.png)

**Tags:** r, python, heatmap, complexheatmap
> **Comments:**
> **username_1**: Are you using R or Python, i.e. you need a Dataframe and its what language you are okay with? Secondly, are you fine doing a single colour heat map? For example even I know with ggplot2 this is easy if you're using uniform colour scheme?  
> **username_0**: I'm okay with both, but I prefer more on Python. It's okay if you want to show me the single colour heat map with ggplot2 (I'm okay with R).  
> **username_2**: If you're not married to this idea and just wish to show correlations and significance at the same time, R's corrplot can do this. It uses `*`, `**` etc. as content to show p-value thresholds, and a color scale to show correlation value.  

---

## 1 answers

### Answer by username_1 on 2022-03-22. Score: 1 | Accepted answer

This solution doesn't reproduce the plot, but it would do if the numerical ranges between the triangles do not overlap.
import matplotlib.pyplot as plt
import seaborn as sns

xx = plt.get_cmap('rocket').copy()
xx.set_under('none')
yy = plt.get_cmap('mako').copy()
yy.set_over('none')
axis = sns.heatmap(dataframe, vmin=-1, cmap=xx, cbar_kws={'pad': -0.04})
sns.heatmap(dataframe, vmin=0, vmax=1, cmap=yy, ax=axis)
plt.show()

My colour schemes are not great but they are distinct, you can search for more here:
https://seaborn.pydata.org/tutorial/color_palettes.html
The idea is this would address a situation where you compare the r-value OR a p-value against another set of values where are > 1. That's what the vmin and vmax are doing.
This is a ONE np array or dataframe solution. In other words you will need to combine your data sets. The solution you want is a two dataframes in one heatmap square. You can put two triangles side-by-side, i.e. one dataframe per heatmap, but I don't know who to place two separate dataframes in one heatmap.


---

