I’m trying to use Plot.ly with Python to create a 3D Surface from a Pandas DataFrame. Nevertheless, the charts appears empty, and this error is shown in console:
js: Uncaught Error: cwise: Arrays do not all have the same shape!
I’m currently on Python 3.6.5 and Plot.ly 3.1.0. Any suggestion?
My code:
import plotly
import plotly.graph_objs as go
import pandas as pd
df = pd.read_csv('test.csv')
data = [go.Surface(x=df.strike,
y=df.expiration_date,
z=df.iv)]
layout = go.Layout(showlegend=True, title='IV surface')
fig = go.Figure(data=data, layout=layout)
raw_html = '<html><head><meta charset="utf-8" />'
raw_html += '<script src="{}"></script></head>'.format(plotly_lib)
raw_html += '<body>'
raw_html += plotly.offline.plot(fig, include_plotlyjs=False, output_type='div', link_text='')
raw_html += '</body></html>'