How to rotate head row cell entries of pgfplotstable

There must be another key to reach this but I can't remember it so I did it a little laborously.

\documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{pgfplotstable}

    \pgfplotstableset{
        every head row/.style={
            before row=\hline,
            after row=\hline\hline,
            typeset cell/.code={
            \ifnum\pgfplotstablecol=\pgfplotstablecols
            \pgfkeyssetvalue{/pgfplots/table/@cell content}{\\}%
            \else
            \pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{##1}&}%
            \fi
            }
        },
        every last row/.style={
            after row=\hline
        },
        every first column/.style={
            column type/.add={|}{}
        },
        every last column/.style={
            column type=||l|
        },
        color cells/.style={
            col sep=&,
            row sep=\\,
            string type,
            postproc cell content/.code={%
                    \pgfkeysalso{@cell content=\rule{0cm}{2.4ex}%
                    \pgfmathsetmacro\y{max((##1 * 100), 0}%
                    \edef\temp{\noexpand\cellcolor{black!\y}}\temp%
                    \pgfmathtruncatemacro\x\y%
                    \ifnum\x>50 \color{white}\fi%
                    ##1}%
                    },
            columns/x/.style={
                column name={},
                postproc cell content/.code={}
            }
        }
    }

\begin{document}
    \begin{table}
    \centering
    \pgfplotstabletypeset[color cells]{
        desc1 & desc2 & desc3 & desc4 & x \\
        0.9 & 0.1 & 0 & 0 & desc1 \\
        0 & 0.8 & 0.1 & 0.1 & desc2 \\
        0 & 0 & 0.95 & 0.05 & desc3 \\
        0 & 0.1 & 0.05 & 0.85 & desc3 \\
    }
    \end{table}
\end{document}

enter image description here


I tried the solution given by @percusse, but it didn't show the desired result, e.g. no rotated header.

It seems that the typeset cell key is being ignored by the every head row selector - at least with pgfplotstable v1.5.1 that I am using.

A slight modification using the comment on another topic over at sf.net by Christian Feuersaenger did produce the desired output!

The key change is to apply the typeset cell on the whole table and use conditionals to isolate the part of the tabular we want to modify.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}

\pgfplotstableset{
    %MODIFICATION START
    typeset cell/.append code={%
        \ifnum\pgfplotstablerow<0%head rows are -1
            \ifnum\pgfplotstablecol=\pgfplotstablecols%special treatment for last column
                \pgfkeyssetvalue{/pgfplots/table/@cell content}{\\}%
            \else
                \pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{#1}&}%
            \fi
        \fi
    },
    every head row/.style={
        before row=\hline,
        after row=\hline\hline,
    },
    %MODIFICATION END
    every last row/.style={
        after row=\hline
    },
    every first column/.style={
        column type/.add={|}{}
    },
    every last column/.style={
        column type=||l|
    },
    color cells/.style={
        col sep=&,
        row sep=\\,
        string type,
        postproc cell content/.code={%
                \pgfkeysalso{@cell content=\rule{0cm}{2.4ex}%
                \pgfmathsetmacro\y{max((##1 * 100), 0}%
                \edef\temp{\noexpand\cellcolor{black!\y}}\temp%
                \pgfmathtruncatemacro\x\y%
                \ifnum\x>50 \color{white}\fi%
                ##1}%
                },
        columns/x/.style={
            column name={},
            postproc cell content/.code={}
        }
    }
}
\begin{document}
\begin{table}
\centering
\pgfplotstabletypeset[color cells]{
    desc1 & desc2 & desc3 & desc4 & x \\
    0.9 & 0.1 & 0 & 0 & desc1 \\
    0 & 0.8 & 0.1 & 0.1 & desc2 \\
    0 & 0 & 0.95 & 0.05 & desc3 \\
    0 & 0.1 & 0.05 & 0.85 & desc3 \\
}
\end{table}
\end{document}

In my case I wanted to change the appearance of the head row, so may I suggest modifying the question to a more general form? that way more people with similar problems, like this closed question, will be drawn to this discussion.

Thanks again to @percusse and Christian Feuersaenger for pointing me to the right direction. I missed the importance of using \pgfkeyssetvalue in the manual ;)!