santosjorge / cufflinks

Productivity Tools for Plotly + Pandas
MIT License
3.03k stars 676 forks source link

AttributeError: 'Layout' object has no attribute 'get' when trying to create distplot #222

Closed xoelop closed 4 years ago

xoelop commented 4 years ago

I'm trying to create a distplot using cufflinks, but if always fails with the same message. For example, trying some of the example code in the documentation: cf.datagen.distplot(3).iplot(kind='distplot',bin_size=.1)

Fails with this error message. Showing a part of the traceback here:

~/opt/anaconda3/lib/python3.7/site-packages/plotly/io/_html.py in to_html(fig, config, auto_play, include_plotlyjs, include_mathjax, post_script, full_html, animation_opts, default_width, default_height, validate)
    155     # Get div width/height
    156     layout_dict = fig_dict.get("layout", {})
--> 157     template_dict = fig_dict.get("layout", {}).get("template", {}).get("layout", {})
    158 
    159     div_width = layout_dict.get("width", template_dict.get("width", default_width))

~/opt/anaconda3/lib/python3.7/site-packages/plotly/basedatatypes.py in __getattr__(self, prop)
   4386             return validator.present(self._compound_props[prop])
   4387         else:
-> 4388             return super(BaseLayoutHierarchyType, self).__getattribute__(prop)
   4389 
   4390     def __getitem__(self, prop):

AttributeError: 'Layout' object has no attribute 'get'

I'm suspecting that what fig_dict.get("layout", {}) returns is not a dictionary, but have no time to dig further into this now

I'm running cufflinks 0.17.0 and plotly 4.3.0

hotessy commented 4 years ago

Facing the same issue.

hotessy commented 4 years ago

I found a solution to this @xoelop. Try fig = cf.datagen.distplot(3).figure(kind='distplot',bin_size=.1); fig.show() instead.

Though I'm not sure why this actually works!

santosjorge commented 4 years ago

This should be now fixed on 0.17.4