# Constructing Two Triangle Heatmaps in One Square

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! • 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__
Mar 22, 2022 at 13:19
• 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). Mar 22, 2022 at 13:20
• 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. Mar 22, 2022 at 17:01

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.