Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 具有绘图功能的基本条形图_Python_Plot_Plotly - Fatal编程技术网

Python 具有绘图功能的基本条形图

Python 具有绘图功能的基本条形图,python,plot,plotly,Python,Plot,Plotly,我试着做一个条形图,用这个代码 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') 但我有一个错误: 在绘图中(图\或\数据、验证、**绘图\选项)

我试着做一个条形图,用这个代码

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')
但我有一个错误:

在绘图中(图\或\数据、验证、**绘图\选项) 239 240绘图选项=\绘图选项\逻辑(绘图选项) -->241 res=\u发送到\u打印(图,**打印选项) 242如果res['error']='': 243如果绘图选项[‘自动打开’]:

C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
在“发送”到“打印”中(图,**打印选项) 1401 cls=utils.PlotlyJSONEncoder) 1402凭证=获取凭证() ->1403验证_凭证(凭证) 1404用户名=凭证['username'] 1405 api_key=凭证['api_key']

C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
在验证\u凭据(凭据)中 1350 api_key=凭证.get('api_key')) 1351如果不是用户名或api_密钥: ->1352引发异常。PlotlyLocalCredentialsError() 1353 1354年

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.
有什么办法帮我吗


谢谢

您需要注意错误中的回溯。在这种情况下,它甚至比平常更有用。这里为您提供了解决方案:

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密钥,该密钥与您的密码不同。

您需要注意错误中的回溯。在这种情况下,它甚至比平常更有用。这里为您提供了解决方案:

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密钥,但该密钥与您的密码不同

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.