chuachu
chuachu

Reputation: 23

I cannot plot with iplot

I am new to plotly and this is the code I've written on 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)

And this is the error I get:

PlotlyRequestError: Authentication credentials were not provided.

I also changed plotly.plotly to chart_studio.plotly because I had another error there.

What can I do?

Upvotes: 2

Views: 768

Answers (1)

rpanai
rpanai

Reputation: 13447

Do you mind to try if this is working:

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()

Upvotes: 1

Related Questions