I have a tabular with a few values, which I want to color-code with \textcolor. The color scheme is given by a colormap:

\begin{tabular}{|c|c|c|c|c|} \hline
    A & \textcolor{mypink}{0.64} & \textcolor{myred}{1.64} & \textcolor{myyellow}{2.64} & \textcolor{myblue}{4.64}   \\ \hline
    B & 125000 & 100000 & 50000 & 0  \\ \hline
    C & 1.23 & 2.00 & 2.00 & 2.00  \\ \hline
hide axis,
scale only axis,
point meta min=0,
point meta max=150000,
colorbar style={
    ytick={0, 50000,100000,150000}
\addplot [draw=none] coordinates {(0,0)};

where mypink, myblue, myred, and myyellow are defined as

\definecolor{mypink}{RGB}{219, 48, 122}
\definecolor{myred}{RGB}{219, 0, 0}
\definecolor{myyellow}{RGB}{0, 255, 244}
\definecolor{myblue}{RGB}{0, 0, 122}

The colors of line A are based on a metric shown in line B, which ranges from 0 to 150000, the scale of the colormap. I want to define textcolors based on that metric, and remove line B from the table. For example, instead of saying mypink on the cell, I'd use a color{125000} (where 125000 is the color metric of that cell) to obtain the appropriate color based on the color map.

How can I do this? I've seen suggestions to index of colormap or color of colormap, but I'm not sure how to use these here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.