zauguin / luaicc

0 stars 0 forks source link

Coloring table cells based on their values #1

Closed ttusar closed 1 year ago

ttusar commented 1 year ago

I would like to be able to color table cells based on their values such as shown here: https://www.siavoosh.com/blog/2019/01/05/latex-table-cell-coloring-based-on-values-in-the-cell/ (the code to produce this example is available at https://www.overleaf.com/read/dywhsntqpzbk), but using perceptually uniform color maps that you provide in this repository. Can this be done?

image

zauguin commented 1 year ago

This is not really an issue, but you can do something like https://gist.github.com/zauguin/0d8360374c851871de39c8869e71246a (This uses CIELuv). Here the difference is rather minimal though, mostly you just see effects from using a cylindrical space and not from using a uniform one. So you would get quite similar results by using HSB.

ttusar commented 1 year ago

This works great and is exactly what I was looking for, thank you so much for taking the time to do it!

ttusar commented 1 year ago

Now that I've played with it a bit more I actually have an additional question - is there a way to change the color of the text in the cell depending on the lightness of the background color?

In the example below it is hard to read the values above 0.8 - it would be great to automatically use white as font color:

image

zauguin commented 1 year ago

Fundamentally luaicc converts between ICC color profiles. So if you want to use it to determine the lightness of a color, you can create an ICC profile representing a monochrome colorscheme which only corresponds to the lightness, e.g. as in https://gist.github.com/zauguin/392687c327c5345458520a9f9ae60287

ttusar commented 1 year ago

This does not work for me, I guess the lightness.icc is missing.

ttusar commented 1 year ago

Apologies, I didn't see that you have included that file as well.

Works like a charm, many thanks again!