Python View and Color Manager

Hi All, I’ve come across this thread linking Color Manager to R View

I’m wondering if anybody has made the same approach in Python View?

Thanks :smile:

Hi @codvknime,
I had a quick look but it looks like a pandas DataFrame (that is what is being converted and imported in the Python View node) is not able to store the colors attached to the KNIME Table by the Color Manager node. I will open a ticket and make sure developers are made aware of this and provide an easy workaround. Sorry for the inconvenience.

@MarcelW are you aware of a workaround?

I am not exactly sure how one would store a piece of colour information with a Pandas data frame. I constructed a script that would extract the colour settings from the KNIME colour manager and store them as a Python dictionary object and save that as a pickle file.

This dictionary will later be loaded back into the Python script and be used as a palette with seaborn or as a colour dictionary for matplotlib.


OK admittedly not the most straightforward solution but hey it can be done after all.

After you throw in the Color Manager

The result from Python looks like this.

For the fun of it there is also a Jupyter notebook included in a subfolder /script/ that I used to first test the concept.


Assuming you are using the Color Manager for nominal columns only, you could also simply append the actual (integer) R, G, B, A values of each row’s color as additional columns, using the Extract Color and Joiner nodes.

Here is an example that does this. Note that I did not implement the Python side that actually uses the color values as @mlauber71’s example already illustrates how this can be done.



Wow! This is exactly what I need. A lot of charts I’m using in my workflows are Python View charts.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.