I am trying to generate a 3D surface using Plotly’s streaming API and I receive no errors in the actual Python code however I get the “Oops! An error occured while loading this plot’s data” on Plotly. Here is my code:
import plotly.plotly as py
import plotly.tools as tls
import plotly.graph_objs as go
from random import uniform
import pandas as pd
import time
tls.set_credentials_file(username='sterlingbutters', api_key='2dc5zzdbva')
stream_id = tls.get_credentials_file()['stream_ids']
token = stream_id[-1]
stream_id = dict(token=token)
z = []
surface = go.Surface(z=z, stream=stream_id)
data = [surface]
layout = go.Layout(
title='Test',
autosize=False,
width=500,
height=500,
margin=dict(
l=65,
r=50,
b=65,
t=90
)
)
fig = go.Figure(data=data, layout=layout)
plot_url = py.iplot(fig, filename='elevations-3d-surface', auto_open=True)
s = py.Stream(stream_id=token)
s.open()
matrices = []
for p in range(5):
matrix = []
for x in range(25):
row = []
for y in range(25):
row.append(uniform(25, 100))
matrix.append(row)
test = pd.DataFrame(matrix)
print(test)
matrices.append(matrix)
print(pd.DataFrame(matrices[1]))
i = 0
while True:
step = 3
z = matrices[i]
s.write(go.Surface(z=z))
time.sleep(step)
i += 1
if i == len(matrices):
i = 0
print(i)
# print(pd.DataFrame(z))
s.close()