Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I found some code to asign colors to table values with PGFplotstable, but unfortunately it is only designed for tables where the topmost row is a head row (which is ignored by postproc). I also need the first column to be ignored by postproc - probably realtively simple but I just cant find how to do it.

This is the code:

\pgfplotstableset{
    color cells/.style={
        col sep=comma,
        string type,
        postproc cell content/.code={%
                \pgfkeysalso{@cell content=\rule{0cm}{2.4ex}%
                \pgfmathsetmacro\y{min(100,max(0,abs(round(##1 * 0.5))))}%
                \ifnum##1<0\edef\temp{\noexpand\cellcolor{blue!\y}}\temp\fi%
                \ifnum##1>0\edef\temp{\noexpand\cellcolor{red!\y}}\temp\fi%
                \pgfmathtruncatemacro\x\y%
                \ifnum\x>50 \color{white}\fi%
                ##1}%
                }
    }
}

\begin{table}\caption{Correlation or something}
\centering
\pgfplotstabletypeset[color cells]{
a,b,c,d
x,-300,-200,-100
y,0,100,200
z,300,40,800
}
\end{table}

(original source is: Drawing heatmaps using TikZ)

The code does not work, as the values in the first column are not numbers - i just want to ignore them, leaving those cells as they are.

share|improve this question
    
Welcome to TeX.SX! –  Claudio Fiandrino Dec 3 '13 at 11:05
add comment

1 Answer 1

Ahhh I found it, pretty simple actually: I start the tabe with the attribute 'columns/a/.style={reset styles,string type}' :

\pgfplotstabletypeset[color cells, columns/a/.style={reset styles,string type}]

Where 'a' is the name of my first column !

Hope this helps someone else ;)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.