Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix PlotlyRequestError?

Tags:

python

plotly

I get an 'PlotlyRequestError: No message' when I execute the code.

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

Filedata = pd.read_csv('C:\\Documents\\Book4.csv')
data = [go.Scatter(x=Filedata.ix[:,0],y=Filedata.ix[:,1])]
layout = go.Layout(
title='Analysis 2016',
xaxis=dict(title='Startdate'),
yaxis=dict(title='Conductivity'))

fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
like image 375
Kathy Avatar asked May 17 '17 12:05

Kathy


2 Answers

I had the same issue and I solved the problem by importing plotly like this:

import plotly.plotly as py
import plotly.graph_objs as go
# these two lines allow your code to show up in a notebook
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode()

And then calling iplot like this:

plotly.offline.iplot(...)
like image 56
Matheus Eduardo Freitag Avatar answered Nov 14 '22 05:11

Matheus Eduardo Freitag


This is because you are trying to plot online which requires credentials based authentication. To plot offline, use plotly.offline's plot class to accomplish this without authentication.

from  plotly.offline import plot

and then use this plot to plot your figure.

like image 31
Ashutosh Gupta Avatar answered Nov 14 '22 04:11

Ashutosh Gupta