我是新手,这是我在kaggle上编写的代码:
import chart_studio.plotly as py
import plotly.graph_objects as go
df = timesData.iloc[:100,:]
traceC = go.Scatter(
x = df.world_rank,
y = df.citations,
mode = "lines",
name = "citations",
marker = dict(color = "rgba(160, 151, 216, 1)"),
text = df.university_name
)
traceT = go.Scatter(
x = df.world_rank,
y = df.teaching,
mode = "lines+markers",
name = "teaching",
marker = dict(color = "rgba(5, 181, 194, 1)"),
text = df.university_name
)
data = [traceC, traceT]
layout = dict(title = "Citation and Teaching vs World Rank of Top 100 Universities",
xaxis = dict(title = "World Rank", ticklen = 5, zeroline = False))
fig = dict(data = data, layout = layout)
iplot(fig)
这是我得到的错误:
PlotlyRequestError:未提供身份验证凭据。
我也将plotly.plotly更改为chart_studio.plotly,因为那里还有另一个错误。
我该怎么办?
答案 0 :(得分:1)
您介意尝试一下是否可行:
import pandas as pd
import plotly.graph_objs as go
df = timesData.iloc[:100,:]
traceC = go.Scatter(
x = df.world_rank,
y = df.citations,
mode = "lines",
name = "citations",
marker = dict(color = "rgba(160, 151, 216, 1)"),
text = df.university_name
)
traceT = go.Scatter(
x = df.world_rank,
y = df.teaching,
mode = "lines+markers",
name = "teaching",
marker = dict(color = "rgba(5, 181, 194, 1)"),
text = df.university_name
)
data = [traceC, traceT]
layout = dict(title = "Citation and Teaching vs World Rank of Top 100 Universities",
xaxis = dict(title = "World Rank", ticklen = 5, zeroline = False))
fig = go.Figure(data=data,
layout=layout)
fig.show()