How to create `pgfplotstable` confusion matrix ?
================================================

Situation
---------

I want to create a confusion matrix (for [example like this](http://www.scikit-yb.org/tr/latest/api/classifier/confusion_matrix.html)), reading data from a file and displaying it flexibly.
Moreover, I found these two:

* [Drawing a large binary matrix as colored grid in TikZ](https://tex.stackexchange.com/a/123728/74942)   

[![](https://i.stack.imgur.com/l3VMW.png)](https://tex.stackexchange.com/a/123728/74942)
* [Drawing heatmaps using TikZ](https://tex.stackexchange.com/a/83865/74942)   

[![](https://i.stack.imgur.com/wszAQ.png)](https://tex.stackexchange.com/a/83865/74942)

which have all features that only need to be combined.
However, I was unable to do so (for MWE, where I tried to mingle the code together, see below).
I would like to keep the `pgfplotstable` command for its options (colormaps, easy setup of min and max).

The MWE-Result:

[![](https://i.stack.imgur.com/1gYlv.png)](https://i.stack.imgur.com/1gYlv.png)

Problem
-------

The Problem is, that I don't know how to combine the two aforementioned MWEs.
I don't really know how the colormap is applied in the first, the scaling is done or how the text is hidden in the second.
The scale-method described [there](https://tex.stackexchange.com/a/455231/74942) ([`\resizebox` as well](https://tex.stackexchange.com/a/159167/74942)) does not allow for specific sizes, i.e. `sx=2, sy=100` (mostly squares).
I am aware of [this post](https://tex.stackexchange.com/a/86849/74942), but would prefer to use colormaps.

Question
--------

> 
> How to create colormap-colored `pgfplotstable` confusion matrix with specifically set cell sizes (row heights together with column width) ?
> 
> 
> 

`MWE`

```
% https://tex.stackexchange.com/a/83865/

\documentclass{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{colortbl}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\usepackage{tikz}    

\usepgfplotslibrary{colormaps}

\pgfplotstableset{
    /color cells/min/.initial=0,
    /color cells/max/.initial=1000,
    /color cells/textcolor/.initial=,
    %
    % Usage: 'color cells={min=<value which is mapped to lowest color>, 
    %   max = <value which is mapped to largest>}
    color cells/.code={%
        \pgfqkeys{/color cells}{#1}%
        \pgfkeysalso{%
            postproc cell content/.code={%
                % inserted by me: https://tex.stackexchange.com/a/123728
                \pgfkeysalso{@cell content=\rule{0cm}{2.4ex}}
                %
                \begingroup
                %
                % acquire the value before any number printer changed
                % it:
                \pgfkeysgetvalue{/pgfplots/table/@preprocessed cell content}\value
                \ifx\value\empty
                    \endgroup
                \else
                \pgfmathfloatparsenumber{\value}%
                \pgfmathfloattofixed{\pgfmathresult}%
                \let\value=\pgfmathresult
                %
                % map that value:
                \pgfplotscolormapaccess
                    [\pgfkeysvalueof{/color cells/min}:\pgfkeysvalueof{/color cells/max}]
                    {\value}
                    {\pgfkeysvalueof{/pgfplots/colormap name}}%
                % now, \pgfmathresult contains {<R>,<G>,<B>}
                % 
                % acquire the value AFTER any preprocessor or
                % typesetter (like number printer) worked on it:
                \pgfkeysgetvalue{/pgfplots/table/@cell content}\typesetvalue
                \pgfkeysgetvalue{/color cells/textcolor}\textcolorvalue
                %
                % tex-expansion control
                % see https://tex.stackexchange.com/questions/12668/where-do-i-start-latex-programming/27589#27589
                \toks0=\expandafter{\typesetvalue}%
                \xdef\temp{%
                    \noexpand\pgfkeysalso{%
                        @cell content={%
                            \noexpand\cellcolor[rgb]{\pgfmathresult}%
                            \noexpand\definecolor{mapped color}{rgb}{\pgfmathresult}%
                            \ifx\textcolorvalue\empty
                            \else
                                \noexpand\color{\textcolorvalue}%
                            \fi
                            \the\toks0 %
                        }%
                    }%
                }%
                %
                \endgroup
                %
                \temp
                \fi
            }%
        }%
    }
}

% https://tex.stackexchange.com/a/148141
\pgfplotscreatecolormap{test}{
    [1pt] % colormap steps: 1pt
    color(-20pt)=(red);
    color(-10pt)=(red!10!white);
    color(0pt)=(white);
    color(10pt)=(green!10!white);
    color(20pt)=(green);
}

\begin{document}

\pgfplotstableread[col sep=comma]{
 50, -100, -70, -10
-20,    0, 100,  20
  5,   30,  40, 800
  3,   30,  50,  70
}\mymatrix

\pgfplotstabletypeset[
    col sep=comma,
    /pgfplots/colormap name=test,
    color cells={
        min=-100,
        max=100
    },
]\mymatrix

\end{document}

```