首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基本条形图

基本条形图
EN

Stack Overflow用户
提问于 2016-08-29 14:27:13
回答 1查看 2.5K关注 0票数 1

我试着用下面的代码做一个条形图

代码语言:javascript
运行
复制
import plotly.plotly as py
import plotly.graph_objs as go

data = [go.Bar(
            x=['giraffes', 'orangutans', 'monkeys'],
            y=[20, 14, 23]
    )]

py.iplot(data, filename='basic-bar')

但我发现了一个错误:

C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py中的PlotlyLocalCredentialsError跟踪(最近一次调用)在() 3 y=20,14,23 4 )] -->5 py.iplot(data,filename=‘basic’) 在dict(figure_or_data,**plot_options) 149中,如果'auto_open‘不在plot_options: 150个auto_open_options’‘auto_open’= False --151个url =plot_options(figure_or_data,**plot_options) 152如果是isinstance(figure_or_data,dict): C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py 在图(figure_or_data,‘auto,**plot_options) 239 240 plot_options = _plot_option_logic(plot_options) --> 241 res =_send_to_plotly(图,**plot_options) 242中,如果res’**plot_options‘错误:243个plot_options_plot_options_options’‘auto_open’: C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py 在_send_to_plotly(图,**plot_options) 1401 cls=utils.PlotlyJSONEncoder中,1402凭据= get_credentials() -> 1403 validate_credentials(凭据) 1404用户名=凭据‘1405 api_key =凭据’‘api_key’ C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py 在validate_credentials(凭据) 1350 api_key = credentials.get('api_key') 1351中,如果没有用户名或没有api_key:-> 1352引发exceptions.PlotlyLocalCredentialsError() 1353 1354 PlotlyLocalCredentialsError:无法在本地机器上为您找到“用户名”、“api-key”对。要暂时登录(直到停止运行Python),运行:>>> import plotly.plotly as py >>> py.sign_in('username','api_key')更好,使用'tools‘模块:>>> import plotly.tools as tls >>> tls.set_credentials_file(username='username',api_key=’api_key‘)永久保存凭据以获得更多帮助,请参见https://plot.ly/python

能帮我个忙吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-29 14:37:06

您需要注意错误中的跟踪。在这种情况下,它甚至比平常更有帮助。这里给出了解决办法:

代码语言:javascript
运行
复制
PlotlyLocalCredentialsError: 
Couldn't find a 'username', 'api-key' pair for you on your local machine. To sign in temporarily (until you stop running Python), run:
>>> import plotly.plotly as py
>>> py.sign_in('username', 'api_key')

Even better, save your credentials permanently using the 'tools' module:
>>> import plotly.tools as tls
>>> tls.set_credentials_file(username='username', api_key='api-key')

For more help, see https://plot.ly/python. 

因此,在尝试制作一个情节之前,请输入您在注册该网站时使用的凭据。您可能需要在web浏览器中登录并请求生成API密钥,这与您的密码不一样。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39208680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档