0

I'm trying to create a groupplot of two heatmaps which share the same colorbar (the goal is that equal values in each of the two heatmaps are mapped to the same color, even if the min and max values are different). How can I achieve this? Here is the code I put together so far:

\begin{tikzpicture}
    \tikzstyle{every node}=[font={\fontsize{12pt}{12}\selectfont}]
    \begin{groupplot}[
        group style={
            group name=my plots,
            group size=2 by 1,
            xlabels at=edge bottom,
            ylabels at=edge left,
            horizontal sep=2cm,vertical sep=3cm,},
            enlargelimits=false,
            colorbar,
            colormap/Blues,
            xticklabels={LPIBG, ALL, HPIBG},
            xtick={0,...,2}
            ]
        \nextgroupplot[
        title={1}%,
        %legend style={at={(0.5,-0.2)},anchor=north,legend columns=3,fill=none,draw=none,align=center}
        ]
        \addplot [matrix plot,point meta=explicit]
        coordinates {
            (0,0) [0] (1,0) [1] (2,0) [2]
        (0,1) [15] (1,1) [4] (2,1) [20]

        (0,2) [6] (1,2) [7] (2,2) [30]
    };
    \nextgroupplot[
    title={2}%,
    %legend style={at={(0.5,-0.2)},anchor=north,legend columns=3,fill=none,draw=none,align=center}
    ]
    \addplot [matrix plot,point meta=explicit]
    coordinates {
        (0,0) [0] (1,0) [1] (2,0) [2]

        (0,1) [3] (1,1) [9] (2,1) [15]

        (0,2) [10] (1,2) [7] (2,2) [8]
    };
\end{groupplot}

\end{tikzpicture}

Output of the code above

So far, each heatmap has its own colorbar.

  • See https://tex.stackexchange.com/a/388959/161015 – Simon Dispa Mar 17 '22 at 17:16
  • This does not answer my question since same numerical values are not mapped to the same color in both plots. – user17579347 Mar 18 '22 at 07:34
  • There are multiple ways to do so. One way is shown in https://tex.stackexchange.com/a/372105/95441. The important part is to set point meta min and point meta max to the same values. Then colors should match the values (of course using the same colormap). If this hint isn't sufficient, ping me and I'll write a complete (more minimal) answer to the question. Good luck!! – Stefan Pinnow Mar 18 '22 at 14:20
  • Did that work or do you need further assistance? – Stefan Pinnow Mar 22 '22 at 11:51

0 Answers0