Rainbow
Rainbow

Reputation: 85

The python plotly: PlotlyError

I am learning the python plotly at https://plot.ly/python/offline/ And when I try this example:

import plotly.plotly as py 
fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
iplot(fig)

the answer gives me this error:

---------------------------------------------------------------------------
PlotlyError                               Traceback (most recent call last)
<ipython-input-13-71d04f672671> in <module>()
      1 import plotly.plotly as py
      2 
----> 3 fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
      4 iplot(fig)

D:\ProgramData\Anaconda2\lib\site-packages\plotly\plotly\plotly.pyc in get_figure(file_owner_or_url, file_id, raw)
    407                 "'{1}'."
    408                 "\nRun help on this function for more information."
--> 409                 "".format(url, plotly_rest_url))
    410         head = plotly_rest_url + "/~"
    411         file_owner = url.replace(head, "").split('/')[0]

PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, 'https://plot.ly/~jackp/8715', we expected it to start with 'https://plotly.your-company.com'.
Run help on this function for more information.

I don't know where the error is, and I think it may be the url https://plotly.your-company.com is broken.

Upvotes: 1

Views: 1903

Answers (2)

Prasad Sonar
Prasad Sonar

Reputation: 1

plotly.plotly functionality moved under chart_studio.Plotly Library which require API key and username to plot it

instead of that follow the below steps to plot any graph which consists of dict object

import plotly.io as pio

pio.show(fig)

Upvotes: 0

Jesse
Jesse

Reputation: 293

Here is the recommended way to get the credentials file. Reading fully through the examples when following a tutorial always helps, setting up your environment properly is important.

  1. Go here and create an account
  2. Go here and get an API key
  3. Type this into your code before you do try to get the figure (must import plotly as well as plotly.plotly):

plotly.tools.set_credentials_file(username='username-from-step-1', api_key='key-you-copied-from-step-2')

This line will grant you access

Edit: iplot(fig) only works on some setups, if you get a new error. Try replacing the line with py.plot(fig)

Upvotes: 2

Related Questions