Number to color

Bjorn's Avatar


09 May, 2014 08:51 PM


I am new to nodebox and I am experimenting with it. I remade my own data visualization with a tutorial I found. I wanna add colors to the rectangles if a certain number is lower than one another. So I am calculating BMI and I want the rectangle to go a certain color.

When the number is:

Between 16 - 18,5 Red
Between 18,5 - 25 Orange
Between 25 - 30 Green
Between 30-40 Orange
Bigger than 40 Red

I just cannot seem to figure it out since my coding is kinda bad.

Appreciating all help!

  1. 1 Posted by rioch on 10 May, 2014 03:42 PM

    rioch's Avatar

    hi Bjorn, here's one way to do it
    maybe a gradient map node could be nice to have

  2. 2 Posted by Bjorn on 13 May, 2014 07:11 PM

    Bjorn's Avatar

    Hi rioch,

    I gave it a shot with the nodebox file you gave me. Sadly I get punched again because I just cannot seem to get it working. I tried multiple things to get it working but the rectangles mostly just disappear.

  3. 3 Posted by rioch on 14 May, 2014 02:19 AM

    rioch's Avatar

    you're right Bjorn, didn't really tried it with a list, sorry for that
    but if you group into a subnetwork it seems to work fine

  4. 4 Posted by Steve Pretty on 24 Jun, 2014 09:54 AM

    Steve Pretty's Avatar

    I may have done something like this. I am interested in using Nodebox as a tool for designing narrow woven bands and braids (rather than writing large probrams in jython as I have in the past!)

    I created a palette of 5 colours (5 colour nodes merged into a list using a combine node). [Thought - it would be an interesting idea to be able to import a palette like this from the Adobe Kuler app].

    I then needed to colour a series of rectangles according to a pattern template string. The string was converted to a list of numbers, and these numbers then serve as an index into the colour list. There does not seem to be an "nth element" node to do this (only a first, second and last) - but the slice node does the job well enough if the slice length is set to 1.

    So make a decision tree to convert your BMI to a number in the range 0 to 4, and use this to index a palette and the output from the palette can colorize your shape.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • Data.ndbx 3.44 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

15 Jul, 2024 07:37 PM
11 Jul, 2024 03:48 PM
28 Jun, 2024 01:51 PM
27 Jun, 2024 02:56 PM
27 Jun, 2024 01:57 PM


26 Jun, 2024 08:17 PM
26 Jun, 2024 11:35 AM
24 Jun, 2024 02:42 AM
24 Jun, 2024 12:46 AM
23 Jun, 2024 08:07 AM
08 Jun, 2024 09:05 AM