Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would Plotly not recognise attribute 'offline'?

Tags:

python

plotly

I'm following the tutorial plotly timeseries, here. I've also amended the code to allow for offline charts in Jupyter, here.

I'm trying to plot a timeseries in Jupyter Notebook. I get the following error.

AttributeError: module 'plotly.plotly' has no attribute 'offline'

As far as I can see I've carried out all the instructions but can't get it to work with the method they suggest.

import plotly.plotly as py
import plotly.graph_objs as go

py.offline.init_notebook_mode()

data = [go.Scatter(x=dataload.date, y=dataload.spend)]

py.offline.iplot(data)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-c9b2e8d8907c> in <module>()
      2 import plotly.graph_objs as go
      3 
----> 4 py.offline.init_notebook_mode()
      5 
      6 data = [go.Scatter(x=dataload.date, y=dataload.spend)]

AttributeError: module 'plotly.plotly' has no attribute 'offline'

Does anyone have a suggestion to why I might be getting this error, could it be a local setup issue?

like image 280
Nick Duddy Avatar asked Jul 21 '17 15:07

Nick Duddy


1 Answers

Just use:

 import plotly
 plotly.offline.init_notebook_mode()

don't use: import plotly.plotly as py

You are referring different documentation. Use https://plot.ly/python/getting-started/#initialization-for-offline-plotting Here it also provides more information regarding how to use help function.

For tutorial in offline mode: https://github.com/SayaliSonawane/Plotly_Offline_Python

like image 105
Sayali Sonawane Avatar answered Sep 26 '22 19:09

Sayali Sonawane