Different colour scheme per facet?

I’m trying to create a customised stacked bar chart showing income and expenses in separate colour schemes like on the pic. Is this possible?

I’ve almost made my notebook look right with the colour bit outstanding. I hope I haven’t massacred the other parts of the code too much — I’m sure there’s a cleaner way to do it.


1 Like

There is only one color scale in Plot, but you can solve the problem differently:

  1. encode the kategoria as color (fill), and the kwota as opacity:
        fill: "kategoria",
        fillOpacity: "kwota",


  1. compute all your colors outside of Plot, and pass them as css color strings:
scale1 = d3.scaleLinear([0, 800], ["white", "orange"]); // outside of Plot
scale2 = d3.scaleLinear([0, 800], ["white", "steelblue"]);

fill: d=> d. kategoria === "Wydatki" ? scale1(d.kwota) : scale2(d.kwota), // in Płot
1 Like

Perfect. Thank you!