Hi
How to set in python view (plotly code) selected items in input table?
Thanks
Hi
How to set in python view (plotly code) selected items in input table?
Thanks
Hello @jibtga
Can you explain further: what you are doing, how your data is, what is the expected output (image, table, chart), what you have already tried so far…
By addressing these bullets, users in forum will know how we can help.
BR
Hi @jibtga,
you should set the custom_data
parameter of the plotly view to the row ids. Our framework adds some code to synchronize the selection. See Python Script API — KNIME Python API documentation for details. However, this does not work for every type of plot.
Hi
First of all, thank you for your time. The “custom_data” its plotly.express.scatter_mapbox parameter, and It works ( ).
Instead if I use graph_objects classes to create the map I can´t get work using “customdata” parameter which I think is the equivalence (I don´t know if I need some code more).
In my case I have to deal with two traces on a scatter_map and I would like to map each traces to a table_views respectively.
This is my code using plotly.express, I can´t work the second trace. But I would like to get work both traces with graph_objetcs
import knime.scripting.io as knio
import plotly.graph_objects as go
import plotly.express as px
import numpy as np
df = knio.input_tables[0].to_pandas()
df2 = knio.input_tables[1].to_pandas()
'''
# use plotly_express
fig = px.scatter_mapbox(
data_frame=df,
lat="Latitud",
lon="Longitud",
hover_data = {"Carretera":True, "PK":True, "Longitud":False, "Latitud":False},
labels = {"texto": "Detector"},
color_discrete_sequence=["fuchsia"],
zoom=10,
mapbox_style="open-street-map",
custom_data=[df.index]
)
fig2 = px.scatter_mapbox(
data_frame=df2,
lat="latitud",
lon="longitud",
hover_data = {"serial":True, "toponimo":True, "nombreMkz":False},
labels = {"texto": "Baliza"},
color_discrete_sequence=["green"],
zoom=10,
custom_data=[df2.index]
)
fig.add_trace(fig2.data[0])
# text over
hovertemp = "<b>%{customdata[1]}</b>, PK: %{customdata[2]} <br>"
# layout
fig.update_layout(
margin={"r":0,"t":0,"l":0,"b":0},
legend=dict(
yanchor="top",
y=0.99,
xanchor="left",
x=0.01,
bgcolor ="rgba(0,0,0,0)"
),
clickmode= "select+event",
dragmode= False
)
fig.update_traces(
marker={'size': 10, 'sizemode':'area'},
hovertemplate=hovertemp
)
knio.output_view = knio.view_plotly(fig)
thanks in advance
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.