# Can we draw a single interactive scatter plot for multiple Y's with each X?

Hi KNIME community,

I am trying to plot the interactive scatter plot with two series of data with KNIME. It is better to have a vertical line connecting two Ys for each X or Row ID.

Here is the link of how to do that via Python Matplotlib. But Python plot is not interactive in KNIME.

I wonder if there is any way of creating the same plot (but interactive with Table of Data, i.e. by selecting one connection in the plot, the row will be selected as well) in KNIME

Data Table Example
X(Row ID) Y1 Y2
0 1 2

1. ``````          4.      7
``````
2. ``````          5.     15
``````

Thanks,
Cheng

Hi @chf42

I am not sure if I fully understood your challenge.
I prepared a small workflow to be executed with âPython Scriptâ and Python Viewâ nodes.

The input is a KNIME DataFrame:

and the requested scatter is in the âPython Viewâ output port:

BR

Hi @chf42
A couple of clarifications about the previous post:

Once released the post, I realised that there were 2 misplaced numbers in the input DF; an i didnât want to edit the whole post by then. The result is just aesthetic as retyping the numbers in the right order within the âTable Creatorâ node, it will fit the proposed matrix.

[âŠ]

As you can see the RowID starts the counting number from zero, but in your example starts in X =1. The chart is plotting at abscissa values 1 and 2, as in the request. This is adjusted in the âPython Scriptâ transformation node. This difference can be easily adjusted in the code at row 10

`df["X"] = df["X"] + 1`

resulting in the feeding data for the scatter chart at âPython Viewâ node.

BR

Hi BR,

Thank you so much for your prompt response! Yes, the Python View can create the plot, but the plot is not interactive, e.g. not interactive with TableView for the same data.

Please see the workflow below. I would like to create a plot that could talk with the table view. Is there any way to do that? We probably need something like PythonView JavaScript version (I guess)

Thanks,
Cheng

1 Like

What about preparing the data so you actually have one column with y values instead of two and than use that column for your plot?

Hi Daniel,

I gave a try, but I couldât create two series scatter plot for the data that has one column with two y values.

The workflow I tried is:

The data table I feed into plotting is:

What I got is:

Should I try something different?

Thanks,
Cheng

Hi @chf42 ,
I wasnât fully aware about the type of interactivity. I wonât be very helpful on functionalities for visualisations nodes in KNIME

However, depending on the degree of interactivity requestedâŠ I mean, if integrating the table and the chart in a single interacting multi-plot is an option; you can give a it a try by customising the chart and the table with Plotly library

Regards

Thanks for the suggestions of using Plotly library. I did check that but I could not find the functionality of sketching multiple Ys with one X in one plot

Hello @chf42,

you can leave each Y in their own column and use Line Plot to get what you want. Only you need a bit different (modified) table structure like this:

To get there you can use âdummyâ Column List Loop with Loop End at the end where you should allow changing table specification and add iteration column which you will use as x-axis column.

Regarding Line Plots there are two you can use - Line Plot (JavaScript) and Line Plot (Plotly) but not sure will theirâs interaction level suit you so might wanna check Refresh Button Widget node. For inspiration check out this blog post:

Br,
Ivan

3 Likes

Thank Ivan! I will give a try. It looks like a great resolution.

1 Like

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