cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Plotly error while plotting into ipywidget output on Databricks

mk3
New Contributor II

Hello, while plotting into databricks notebook with plotly into ipywidget output, I am getting following error SyntaxError: expected expression, got ','. Here is my snippet.

 

 

 

import ipywidgets, random
import plotly.express as px
from plotly.offline import plot
from IPython.display import display, clear_output

out = ipywidgets.Output()
button = ipywidgets.Button(description = 'button')

def on_button_clicked(b):
    with out:
        clear_output(True)
        p = plot( px.scatter(x = [random.randint(1, 100) for i in range(4)], y = [random.randint(1, 100) for i in range(4)]), output_type='div')
        displayHTML(p)

button.on_click(on_button_clicked)
display(button)
out

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @mk3 , Instead of using interactive_output, consider directly displaying the Plotly figure as a widget. You can create a Plotly figure widget and update it dynamically based on widget interactions.

View solution in original post

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @mk3 , Instead of using interactive_output, consider directly displaying the Plotly figure as a widget. You can create a Plotly figure widget and update it dynamically based on widget interactions.

mk3
New Contributor II

Hi, you are right. It seems that figurewidget is the only option, if we need to plot into ipywidgets.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.