I have a table of values and I want the cells to range from green to red depending on their values. I tried the following function:

    \pgfmathparse{#1 <= 256 ? #1 / 256 : 1}
    \pgfmathsetmacro{\g}{1 - \pgfmathresult}
    \cellcolor[rgb]{\r ,\g ,0}\r, \g,  #1

but it just turns every cell green (or red if i flip \r and \g) even when \r is close to one and \g close to 0.

Here's a list of my packages in case it's due to a conflict:


EDIT: The link with the triangular matrix was actually what I was looking for. Thanks I didn't find it while looking up my problem.



Browse other questions tagged or ask your own question.