Number-to-Color translation

I’m trying to change the colour of an object based on a value, but what I’m trying to achieve doesn’t seem possible with the standard Number-to-Color Translation feature.

I’m trying to achieve the following:

Value=0, colour 1
Value=+ve number up to 100, colour 2
Value= greater than 100 up to 200, colour 3

The problem is if I put an entry of 0 in the translation table, it considers any number from 0 to the next entry as one case i.e. it doesn’t consider 0 as a separate case.

Is it possible to do this? I tried putting in an entry of 0.001, but it doesn’t accept floating point numbers, even though the value being compared is a float.

Al

You’re right, the number-to-color binding doesn’t play well with floating point numbers.

You have 2 options:

  1. Use the Styles feature - it handles floating point much better.
  2. Use an expression, with some nested if() functions and the color() function, you can acheive this logic simply.

Thanks for the tips Carl. Styles do handle floating point numbers :slight_smile: - but only to 2 decimal places :frowning: . This means it may not work correctly, as the limit should really be the smallest possible floating point number.

Nested if() statements worked, although the 10 closing brackets are a bit mind boggling! It’s a shame the number-to-color binding doesn’t work. The only way I could see it working in this situation is if you allow the selection of ‘>’, ‘=’ or ‘>=’ for each entry.

Al