1

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.

2
  • 3
    As it says immediately above the example - You need to provide credentials to download figures. Commented Aug 25, 2017 at 10:57
  • Thank you.I try your advice but it didnt work either.how do u modify it Commented Aug 27, 2017 at 2:33

2 Answers 2

2

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)

Sign up to request clarification or add additional context in comments.

Comments

0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.