Number to color
Hello,
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!
- Data.ndbx 3.44 KB
Keyboard shortcuts
Generic
? | 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
1 Posted by rioch on 10 May, 2014 03:42 PM
hi Bjorn, here's one way to do it
maybe a gradient map node could be nice to have
2 Posted by Bjorn on 13 May, 2014 07:11 PM
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 Posted by rioch on 14 May, 2014 02:19 AM
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 Posted by Steve Pretty on 24 Jun, 2014 09:54 AM
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.