Color and legend in Python view

Hi Forum

I have a minor KNIME, but significant scientific, issue.

I have created a double y-axis line plot using Python view. (With a lot of help from the community - thank you for that.)

I lack color and legends on my plot.
It is showing two measurements (temp and torque) from each sample and plotting them over time.

I would like to have a different color for each input. And of course shown in a legend.

Can anybody help me with that?

(Also. If anybody know why it draws those straight lines on the bottom picture, I would be very grateful. They only appear, when I plot more than one sample, but not on any of them individually)

Despite finding suitable topics on trustworthy forums, I have not been successful in implementing them.

Colors:

Legend:

This is the script from my Python view node:

This is the current situation:

If I need to supply additional information’s, please let me know. Unfortunately I can’t upload my workflow due to NDA reasons.

Best regards
Bjarke

1 Like

I suspect the straight lines is time plotted against itself.
I haven’t asked the node to do that, so I don’t know how to get rid of it again.

It is always easier to discuss a working example that one can improve than study code screenshots and take a guess. Sometimes that can work buto more often it might not. So my suggestion would be to create a working example that examplifies your problem so the community might be able to help you with a real KNIME workflow. Typically then the quirks will show up.

1 Like

Hi mlauber

Happy to see you again. Thank you for your assistance.

This will be the first time, I tried to reproduce my errors from a data generator, so I’m not fully aware if I’m excluding some vital information. It looks fine to me (except that the plot makes no sense).
For colors and legends it should work fine, though.

For KNIME forum.zip (333.0 KB)

I hope this helps.
If not, please ask again. It is not lack of willingness, but lack of skills :slight_smile:

Best Bjarke

1 Like

I attached a modified version of your workflow that adds different colors as well as a legend to the view:

For KNIME forum_with_colors_and_legend.knwf (20.3 KB)

Essentially, I only added color arguments to the calls to plot (e.g., ax1.plot(t, data1, 'b'), where ‘b’ means blue), and added a legend to the figure via fig.legend(...) which takes an iterable of handles to the rendered lines (which are returned by plot) and an iterable of their corresponding labels.

Marcel

3 Likes

Hi Marcel

Thank you for your help.

It is undoubtedly me, that has expressed my self in a wrong way.
The red and blue solution I already had figured out. I would like them to be dynamic.
I would like each of my unique inputs to have a different color. Not just each of my list(/arrays?) of torque and temp to be different from each other.

I think it might make more sense, if I try to explain the normal situation.
I am investigating the connection between Torgue and Temperature in multiple flour samples.

Each of these flours should be distinguishable from each other - both in regards to torgue and temp. The only solution I can think of is dynamic coloring. Because I’m not working with a fixed number of samples each time. And giving them the same color for torque and temp will not work. Then I wouldn’t be able to tell the flours from each other.

I hope this clarified my needs and our misunderstanding.

The legend looks good. Thank you for that.
Would you happen to know, if I can control the placement of it? I would like it to be underneath my x axis text.
I can have so many different flour samples, that it will be a problem to have it inside the graph.

Your help is very appreciated, and I hope your can assist me again, now that my needs hopefully are clearer.

Best regards
Bjarke

If anybody have some good suggestions, I am still stuck with this challenge and would be very grateful for a push in the right direction.

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