Using plotly 2.7.0, which has support for cones (https://plot.ly/python/3d-cone/), I’m trying to generate a mesh of cones on a sphere. I can generate the mesh in jupyter or ipython, however I get the traceback below when running in dash. For simplicity, I am only attempting to plot one cone below.
Is it expected that cones do not plot in dash?
import dash
from dash.dependencies import Input, Output, Event, State
import dash_core_components as dcc
import dash_html_components as html
import dash_table_experiments as dt
import plotly.graph_objs as go
app=dash.Dash()
app.scripts.config.serve_locally=True
server=app.server
app.layout=html.Div([
html.Div([
html.H1('Brownian Motion on the Unit Sphere'),
html.H5('Warning, do not refresh the page or all data will be lost!'),
],className = 'container'),
html.Button('Click to plot cone', id = 'plot_cone'),
# 3d chart
html.Div([
html.Div([
dcc.Graph(id='plot-3d-cone', style={'height': 600, 'align': 'center'},className='twelve columns')
],className='row')
],className='container'),
])
@app.callback(
Output('plot-3d-cone', 'figure'),
[Input('plot_cone', 'n_clicks')],
)
def plot_cone(n_clicks):
cone = dict(
type='cone',
x=[1],
y=[1],
z=[1],
u=[1],
v=[0],
w=[0]
)
# Set the layout
noaxis=dict(showbackground=False,
showgrid=False,
showline=True,
showticklabels=True,
ticks='',
title='',
zeroline=False)
layout3d=go.Layout(title='Brownian Motion on Unit Sphere',
font=dict(family='Balto', size=14),
)
fig=go.Figure(dict(data=[cone], layout=layout3d))
return fig
Traceback
[2018-06-19 13:31:10,327] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/app.py”, line 2292, in wsgi_app
response = self.full_dispatch_request()
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/app.py”, line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/app.py”, line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/_compat.py”, line 35, in reraise
raise value
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/app.py”, line 1813, in full_dispatch_request
rv = self.dispatch_request()
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/flask/app.py”, line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/dash/dash.py”, line 558, in dispatch
return self.callback_map[target_id]‘callback’
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/dash/dash.py”, line 515, in add_context
output_value = func(*args, **kwargs)
File “/network/rit/home/ns742711/schiraldilab/repos/earle-viz/test.py”, line 58, in plot_cone
fig=go.Figure(dict(data=[cone], layout=layout3d))
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 1175, in init
super(Figure, self).init(*args, **kwargs)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 377, in init
self.setitem(key, val, _raise=_raise)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 432, in setitem
value = self._value_to_graph_object(key, value, _raise=_raise)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 543, in _value_to_graph_object
_parent=self, _parent_key=key)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 793, in create
return globals()[class_name](*args, **kwargs)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 158, in init
value = self._value_to_graph_object(index, value, _raise=_raise)
File “/network/rit/lab/schiraldilab/bin/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py”, line 1073, in _value_to_graph_object
raise exceptions.PlotlyDataTypeError(self, path)
plotly.exceptions.PlotlyDataTypeError: Invalid entry found in ‘data’ at index, ‘0’
Path To Error: [‘data’][0]
It’s invalid because it doesn’t contain a valid ‘type’ value.
Conda list
# packages in environment at /network/rit/lab/schiraldilab/bin/anaconda3:
#
# Name Version Build Channel
plotly 2.7.0 py36_1