Trying to create colored stacked bars

Yannis's Avatar


09 May, 2018 06:19 PM

I am trying to create stacked bars, i.e. bars with parts of different height in different color. In the attached file there are columns for r,g,b to use for colorization, and an "area" column to define the height of each color within the column. So far, the columns (years) appear fine, but the height is calculated arbitrarily.


  1. Support Staff 1 Posted by john on 09 May, 2018 09:26 PM

    john's Avatar

    Hi Yannis,

    You are making one stack per year and the segments in each year are proportional to the area value in your csv.

    The basic trick is to make one stack at a time using a stack node (not a grid). You need a function which reads in a list of the all the data plus a value indicating the year of that particular stack. This function first filters the data to only rows from that year. Then, for each row, it makes a rectangle with a constant width and a height proportional to area. It then colors each rectangle and uses the stack node to stack them vertically from the bottom up (north). It will then output that stack packaged as a single group.

    This function will spit out one stack for each year you feed into it. You can then use another stack node to arrange your year stacks horizontally (east) and an align node to make sure they all line up on the x axis. It is then easy to add labels for each stack.

    I have created a NodeBox network that does exactly this. See zip file and screenshot. The "make_stack" function is a NodeBox subnetwork. Control click on it and choose Edit Children to open it up and see how it works.

    Please let me know if this helps and don't be afraid to ask more questions!


  2. 2 Posted by Yannis on 10 May, 2018 09:39 AM

    Yannis's Avatar

    Thanks so much! This is all I needed for now. :)

Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • 2.61 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

25 May, 2024 11:52 AM
24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM


13 May, 2024 12:36 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM