The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.

NodeBox 3From the old forum

assign color by lookup?

2 replies Last reply

  1. Hi - I am the definition of a total beginner so hopefully this isn't totally obvious, lol. I'm wondering if there's any way to assign colors based one value in a csv rather than having a bunch of colors repeat.

    so for example in this i have the name of a book & the length of the book in pages showing. i would like to color code each bar (&associated title??) by the key "Genre." I'm fine doing this with random colors for the moment but ideally I'd love to be able to set my own. I started playing around on the left of my network but I got stuck pretty fast.

    Any help appreciated - thanks!!

    Copy link
  2. Hi Micaela,

    Welcome to the NodeBox community.

    You managed to get 95% of the way to your goal. You made the rest of your ring, isolated the distinct possible values of genre and assigned colors to them.

    The problem is that you have 211 books but only 12 distinct genres. How do you map those 12 genres back onto the 211 books?

    The solution is to make a little genre color lookup table before you create your book ring.

    You already have the distinct list of genres and distinct list of colors. All I did was add a make table node to turn that into a two-column lookup table.

    Now all you have to do is, for each line of your table, filter that lookup table to the genre of each book. The filter node will return one row of your lookup table with the genre and the color. Then all you have to do is lookup the color in that table and apply it to your labels and rectangles.

    Updated ndbx file and screenshot attached.

    If you want to use specific colors instead of hue spectrum, just build those colors with 12 color nodes and 2 combine nodes, or just type the RGB codes into a spreadsheet and read them in. Whatever colors you put in your lookup table will be applied to the ring.

    Fun little problem! Thanks for sharing it.

    John

    Copy link
  3. wow, thank you so much!! this is perfect. i appreciate it!

    Copy link

Know something that helps?

Sign in with your email address to reply. No password needed.

Sign in to reply