This is a follow-up question to: Heatmap of a triangular matrix (or a sparse matrix) (where also the code is taken from)
What I want to achieve (Excel draft):
What I got so far (see code at bottom):
What is missing:
- Axis description with "Some Text"
- Removing the "xxx" hack to get the first column being recognized as strings
Possible solution for removing the "xxx" hack: I found that "automatic column numbering" was done here: Diverging color scale for a table heatmap and my dream solution would be not only incorporating it to my heatmap but also extending it with "automatic row numbering".
Current Code:
\documentclass{standalone}
\usepackage{colortbl}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\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={%
%
\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 http://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
}%
}%
}
}
\begin{document}
\vrule\pgfplotstabletypeset[%
color cells={min=365,max=375,textcolor=black},
/pgfplots/colormap={orangewhiteorange}{rgb255=(255,170,0) color=(white) rgb255=(255,170,0)},
/pgf/number format/fixed,
/pgf/number format/precision=0,
col sep=comma,
columns/xxx/.style={reset styles,string type}%
]{%%%%%%%
xxx, 0, 1, 2, 3, 4, 5, 6
0, 370.8, 371.2, 371.1, 370.9, 371.2, 371.6, 372.0
1, 370.4, 370.3, 370.4, 370.7, 370.8, 371.4, 371.5
2, 370.9, , 370.7, 370.9, 370.8, 371.2, 372.1
3, 371.0, , , 368.1, 371.1, 368.8, 371.3
4, 370.9, , , , 371.1, 371.4, 371.4
5, 371.7, , , , , 371.1, 371.4
6, 372.0, , , , , , 371.2
}\vrule
\end{document}
Any help is appreciated!