plotly_ipywidget_notebooks icon indicating copy to clipboard operation
plotly_ipywidget_notebooks copied to clipboard

Interact.ipynb raises exception

Open fkromer opened this issue 5 years ago • 4 comments

When I execute the cells of the Interact.ipynb I get an exception after executing the last cell:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
c:\users\florian\.virtualenvs\data-processing-a_m7qh6p\lib\site-packages\ipywidgets\widgets\interaction.py in update(self, *args)
    254                     value = widget.get_interact_value()
    255                     self.kwargs[widget._kwarg] = value
--> 256                 self.result = self.f(**self.kwargs)
    257                 show_inline_matplotlib_plots()
    258                 if self.auto_display and self.result is not None:

<ipython-input-16-8163515321f0> in update(a, b, color)
      4 def update(a=3.6, b=4.3, color='blue'):
      5     with fig.batch_update():
----> 6         scatt.x=xs
      7         scatt.y=np.sin(a*xs-b)
      8         scatt.line.color=color

c:\users\florian\.virtualenvs\data-processing-a_m7qh6p\lib\site-packages\plotly\basedatatypes.py in __setattr__(self, prop, value)
    349         else:
    350             # Raise error on unknown public properties
--> 351             raise AttributeError(prop)
    352 
    353     def __getitem__(self, prop):

AttributeError: x

Package versions:

ipywidgets==7.5.1
numpy==1.17.3
plotly==4.2.1

fkromer avatar Nov 21 '19 10:11 fkromer

Same here. Does someone have a solution for this?

HannesThielke avatar Mar 13 '20 22:03 HannesThielke

I solved this. Just add .data[0] to add_scatter()

StepanSmirnov avatar May 01 '20 13:05 StepanSmirnov

I was coming here to report the same fix! this fix works. please merge this!

ljburtz avatar Nov 04 '20 07:11 ljburtz

Thank you @StepanSmirnov. It works. BTW what does it mean: ".data[0]"?

almirmav avatar Dec 03 '20 04:12 almirmav