Custom color function in Plot Bar chart

Hi everyone,

I’m trying to have a custom color scheme in a plot chart in this notebook. I’m generating as many plots as I have lines in my table to visualize the repartition of tokens in a given wallet. So a bit like Mike’s sparkbars in the inputs.Table example, but more elaborate. I could do this the d3 way, but I want to get used to using Plot!

How should I proceed? @Fil any ideas? I tried to navigate the Plot doc/API/Cheatsheet, but nothing seemed very obvious to me. Maybe I didn’t look where I should have?

Unless I’m mistaken, there is only one valid bar in your chart—all the other have a non-numerical value for x.

Apologies for not being clearer. Let me rephrase.

I have a color scheme matching problem. I want my legend (categories with collection names such as ‘fxhash’ or ‘Versum Items’) to match the plots in the distribution column. I use a specific function to create the legend, and I would like plot to use that function to do the color attribution. Should I do it the other way around? If yes, how?

(edit, the colors look like they could be matching but they aren’t).

Solution found: I can pass a function in the plot mark like


But this only works if the overal color property of the plot is commented out/doesn’t exist. If it does exist, it trumps the mark-specific fill function. This might be somewhere in the API and I probably have missed it so this is all on me!

Yes, it’s easy to overlook:
“A color scale defaults to identity if no range or scheme is specified and all associated defined values are valid CSS color strings.”