I am trying to implement a diverging color scale; the cells should be coloured according to the values inside. Something similar has been achieved here for sequential color scales.
However, I would like to have a "midpoint", i.e. a color scale from blue to white to red.
This is a minimal working example that does not achieve what I want. What I am looking for is depicted in the comment, but the code does not work. What's wrong there?
\documentclass[12pt]{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableset{
color cells/.style={
col sep=comma,
string type,
postproc cell content/.code={%
\pgfkeysalso{@cell
% content=\rule{0cm}{2.4ex}\cellcolor{\pgfmathtruncatemacro\number{##1}\ifnum\number>50 red!##1!white\else blue!##1!white\fi}}%
content=\rule{0cm}{2.4ex}##1}%
},
columns/x/.style={
column name={},
postproc cell content/.code={}
}
}
}
\begin{table}\caption{Correlation}
\centering
\pgfplotstabletypeset[color cells]{
0,55,100,0,0,0,7,16,10,19,21,29
43,43,90,17,87,8,20,81,43,20,18,31
67,21,50,0,70,5,6,5,26,23,20,25
11,40,60,63,7,14,10,17,24,22,15,38
25,0,33,50,17,16,9,10,22,6,19,22
22,5,0,0,2,50,0,3,8,7,13,18
0,50,30,40,50,1,20,13,3,12,5,11
}
\end{table}
\end{document}

