Thanks @empet! But I still get an error when running your code offline. Online seems to be fine, but using offline mode, I get this stack trace:
PlotlyDictKeyError Traceback (most recent call last)
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/tools.py in return_figure_from_figure_or_data(figure_or_data, validate_figure)
1453 try:
-> 1454 graph_objs.Figure(figure)
1455 except exceptions.PlotlyError as err:
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
1174 def init(self, *args, **kwargs):
-> 1175 super(Figure, self).init(*args, **kwargs)
1176 if ‘data’ not in self:
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
376 for key, val in d.items():
–> 377 self.setitem(key, val, _raise=_raise)
378
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in setitem(self, key, value, _raise)
431 if self._get_attribute_role(key) == ‘object’:
–> 432 value = self._value_to_graph_object(key, value, _raise=_raise)
433 if not isinstance(value, (PlotlyDict, PlotlyList)):
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in _value_to_graph_object(self, key, value, _raise)
542 return GraphObjectFactory.create(key, value, _raise=_raise,
–> 543 _parent=self, _parent_key=key)
544
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in create(object_name, *args, **kwargs)
792 if class_name in [‘Figure’, ‘Data’, ‘Frames’]:
–> 793 return globals()[class_name](*args, **kwargs)
794 else:
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
157 for index, value in enumerate(list(*args)):
–> 158 value = self._value_to_graph_object(index, value, _raise=_raise)
159
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in _value_to_graph_object(self, index, value, _raise)
1306 return super(Frames, self)._value_to_graph_object(index, value,
-> 1307 _raise=_raise)
1308
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in _value_to_graph_object(self, index, value, _raise)
222 _parent=self,
–> 223 _parent_key=index, **value)
224 except exceptions.PlotlyGraphObjectError:
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in create(object_name, *args, **kwargs)
798 else:
–> 799 return PlotlyDict(*args, **kwargs)
800
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
376 for key, val in d.items():
–> 377 self.setitem(key, val, _raise=_raise)
378
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in setitem(self, key, value, _raise)
431 if self._get_attribute_role(key) == ‘object’:
–> 432 value = self._value_to_graph_object(key, value, _raise=_raise)
433 if not isinstance(value, (PlotlyDict, PlotlyList)):
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in _value_to_graph_object(self, key, value, _raise)
542 return GraphObjectFactory.create(key, value, _raise=_raise,
–> 543 _parent=self, _parent_key=key)
544
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in create(object_name, *args, **kwargs)
792 if class_name in [‘Figure’, ‘Data’, ‘Frames’]:
–> 793 return globals()[class_name](*args, **kwargs)
794 else:
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
157 for index, value in enumerate(list(*args)):
–> 158 value = self._value_to_graph_object(index, value, _raise=_raise)
159
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in _value_to_graph_object(self, index, value, _raise)
1074 _parent=self,
-> 1075 _parent_key=index, **value)
1076
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in create(object_name, *args, **kwargs)
798 else:
–> 799 return PlotlyDict(*args, **kwargs)
800
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in init(self, *args, **kwargs)
376 for key, val in d.items():
–> 377 self.setitem(key, val, _raise=_raise)
378
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/graph_objs/graph_objs.py in setitem(self, key, value, _raise)
427 path = self._get_path() + (key, )
–> 428 raise exceptions.PlotlyDictKeyError(self, path)
429 return
PlotlyDictKeyError: ‘lat’ is not allowed in ‘scatter’
Path To Error: [‘frames’][0][‘data’][0][‘lat’]
Valid attributes for ‘scatter’ at path [‘frames’][0][‘data’][0] under parents [‘figure’, ‘frames’, ‘frames_entry’, ‘data’]:
['cliponaxis', 'connectgaps', 'customdata', 'customdatasrc', 'dx',
'dy', 'error_x', 'error_y', 'fill', 'fillcolor', 'hoverinfo',
'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertext', 'hovertextsrc',
'ids', 'idssrc', 'legendgroup', 'line', 'marker', 'mode', 'name',
'opacity', 'r', 'rsrc', 'selected', 'selectedpoints', 'showlegend',
'stream', 't', 'text', 'textfont', 'textposition', 'textpositionsrc',
'textsrc', 'tsrc', 'type', 'uid', 'unselected', 'visible', 'x', 'x0',
'xaxis', 'xcalendar', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'ysrc']
Run <scatter-object>.help('attribute')
on any of the above.
‘’ is the object at [‘frames’][0][‘data’][0]
During handling of the above exception, another exception occurred:
PlotlyError Traceback (most recent call last)
in ()
----> 1 plotly.offline.iplot(fig)
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/offline/offline.py in iplot(figure_or_data, show_link, link_text, validate, image, filename, image_width, image_height, config)
330 config.setdefault(‘linkText’, link_text)
331
–> 332 figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
333
334 # Though it can add quite a bit to the display-bundle size, we include
~/.pyenv/versions/3.6.2/lib/python3.6/site-packages/plotly/tools.py in return_figure_from_figure_or_data(figure_or_data, validate_figure)
1462 "plot option.\nHere’s why you’re "
1463 “seeing this error:\n\n{0}”
-> 1464 “”.format(err))
1465 if not figure[‘data’]:
1466 raise exceptions.PlotlyEmptyDataError(
PlotlyError: Invalid ‘figure_or_data’ argument. Plotly will not be able to properly parse the resulting JSON. If you want to send this ‘figure_or_data’ to Plotly anyway (not recommended), you can set ‘validate=False’ as a plot option.
Here’s why you’re seeing this error:
‘lat’ is not allowed in ‘scatter’
Path To Error: [‘frames’][0][‘data’][0][‘lat’]
Valid attributes for ‘scatter’ at path [‘frames’][0][‘data’][0] under parents [‘figure’, ‘frames’, ‘frames_entry’, ‘data’]:
['cliponaxis', 'connectgaps', 'customdata', 'customdatasrc', 'dx',
'dy', 'error_x', 'error_y', 'fill', 'fillcolor', 'hoverinfo',
'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertext', 'hovertextsrc',
'ids', 'idssrc', 'legendgroup', 'line', 'marker', 'mode', 'name',
'opacity', 'r', 'rsrc', 'selected', 'selectedpoints', 'showlegend',
'stream', 't', 'text', 'textfont', 'textposition', 'textpositionsrc',
'textsrc', 'tsrc', 'type', 'uid', 'unselected', 'visible', 'x', 'x0',
'xaxis', 'xcalendar', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'ysrc']
Run <scatter-object>.help('attribute')
on any of the above.
‘’ is the object at [‘frames’][0][‘data’][0]