question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError when producing an Interactive plot

See original GitHub issue

Plotly 4.1.0

I get an error when I try to run @jonmmease 's Interact notebook:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/opt/anaconda3/lib/python3.7/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-27-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

/opt/anaconda3/lib/python3.7/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

I get the same error wen I run the notebook with Binder.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Sep 10, 2019

Ok, that’s good feedback, thanks!

For reference, the change in behaviour was documented in the version 4 migration guide here: https://plot.ly/python/v4-migration/#add-trace-return-value along with a suggested workaround for adapting older code like the notebook you were initially working from.

1reaction
empetcommented, Sep 10, 2019

@sursu Yes, you are right. Just don’t rename fig.data[0] and replace the above scatt updates as follows:

xs=np.linspace(0, 6, 100)

@interact(a=(1.0, 4.0, 0.01), b=(0, 10.0, 0.01), color=['red', 'green', 'blue'])
def update(a=3.6, b=4.3, color='blue'):
    with fig.batch_update():
        fig.data[0].x=xs
        fig.data[0].y=np.sin(a*xs-b)
        fig.data[0].line.color=color

Please address such questions on Plotly forum https://community.plot.ly/, not here.

Update: I 've just tested the initial @jonmmease’s code on an environment with Plotly 3.0 and it worked. This means that at some point the new plotly upgrades made the code obsolete.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am getting error in plotly module of FB prophet - Stack Overflow
I am getting the following error when executing the below code: Code: from fbprophet.plot import plot_plotly ...
Read more >
AttributeError when creating pyqtgraph plots inside the main ...
I am trying to read some data from a file and plot it using pyqtgraph (as given in the code below). All the...
Read more >
Sage Interactive has Attribute error - Ask Sagemath
Herr is my code for a double integrator interactive I am making that both make a double integral and shows a graph with...
Read more >
Matplotlib pane throwing AttributeError when interactive=True
It throws an AttributeError as get_ipython() returns None instead of an ... ax = plt.subplots() ax.plot([0,1,2], [2,2,4]) pn.pane.plot.
Read more >
Connection between google colab and Anvil is not working
Hi, I would like to show some interactive plots that I have saved as HTML ... AttributeError: module 'anvil' has no attribute 'LiveObject'....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found