I need some heeelp. So, I’m using the example below to replicate the interactivity, but when I select an area on the graph the table doesn’t update on my notebook. I’ve used jupyterlab as well as the regular jupyter-notebook without success. Can anyone test and let me know what i’m doing wrong?
import plotly.graph_objs as go
import plotly.offline as py
import pandas as pd
import numpy as np
from ipywidgets import interactive, HBox, VBox
df = pd.read_csv('https://raw.githubusercontent.com/jonmmease/plotly_ipywidget_notebooks/master/notebooks/data/cars/cars.csv')
f = go.FigureWidget([go.Scatter(y = df['City mpg'], x = df['City mpg'], mode = 'markers')])
scatter = f.data
N = len(df)
scatter.x = scatter.x + np.random.rand(N)/10 *(df['City mpg'].max() - df['City mpg'].min())
scatter.y = scatter.y + np.random.rand(N)/10 *(df['City mpg'].max() - df['City mpg'].min())
scatter.marker.opacity = 0.5
def update_axes(xaxis, yaxis):
scatter = f.data
scatter.x = df[xaxis]
scatter.y = df[yaxis]
f.layout.xaxis.title = xaxis
f.layout.yaxis.title = yaxis
scatter.x = scatter.x + np.random.rand(N)/10 *(df[xaxis].max() - df[xaxis].min())
scatter.y = scatter.y + np.random.rand(N)/10 *(df[yaxis].max() - df[yaxis].min())
axis_dropdowns = interactive(update_axes, yaxis = df.select_dtypes('int64').columns, xaxis = df.select_dtypes('int64').columns)
# Create a table FigureWidget that updates on selection from points in the scatter plot of f
t = go.FigureWidget([go.Table(
fill = dict(color='#C2D4FF'),
align = ['left'] * 5),
cells=dict(values=[df[col] for col in ['ID','Classification','Driveline','Hybrid']],
fill = dict(color='#F5F8FF'),
align = ['left'] * 5))])
t.data.cells.values = [df.loc[points.point_inds][col] for col in ['ID','Classification','Driveline','Hybrid']]
# Put everything together
@mini_geek FYI, I tested the code in a Jupyter notebook, and it worked fine.
To corroborate, you were able to select points on the graph, and the table below showed only the selected points?
This example is working for me as well (the table updates to show selected rows). I’m not sure of what might be going wrong for you. What versions of plotly.py and jupyter notebook do you have installed?
Yes. Everything works as intended: Box-selecting and table update. Since the issue cannot be reproduced, it could be from package installation like Jon suggested.
thanks for the feedback!
plotly ‘3.7.1’ | jupyterlab 4.4.0 | notebook 5.7.8
thanks for the support @knam!
Hi Jon, I reinstall and it does kinda work now. I mean that i am able to select and shows me the query table, but is very slow and memory intensive; table or graph don’t reset when clicking the home icon or when double clicking inside the frame.
notebook: on the java side i have “error trying to load resource 404”, “Unhandled Promise Rejection: Error: Resize must be passed a displayed plot div element.” index.js
jupyter-lab: Error displaying widget. on java countless
Can you try updating your version of plotly.py to 3.10. There have been a couple of FigureWidget updates over the past few releases. If you’re using JupyterLab then also install the
firstname.lastname@example.org JupyterLab extension.
i did, however, i got some unintended consequences. my init_notebook_mode(connected=True) is giving me an error Will give an update when i get this issues resolved. Thanks for the tips.
after some struggling i got it working. I followed installation instructions from: https://libraries.io/npm/plotlywidget, and also had to re-install jupyter lab. Widgets are working on both notebook and lab, albeit still a little slow when resetting axes/selections on the graph, the table does not reset.
Thanks for the support!