Closed
Description
- OS: Ubuntu 16.04
- Python 3.6.6
- plotly version: 3.1.0
As you can convert matplotlib figures to plotly, it should be possible with seaborn figures as well. I tried the following code snipped:
import seaborn as sns
import plotly.offline as ply
import plotly.tools as plytls
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)
ply.iplot_mpl(g.fig)
How the figure looks like:
This results in the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-11-523d3e17715d> in <module>()
----> 1 ply.iplot_mpl(g.fig)
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/offline/offline.py in iplot_mpl(mpl_fig, resize, strip_style, verbose, show_link, link_text, validate, image, image_filename, image_height, image_width)
682 ```
683 """
--> 684 plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose)
685 return iplot(plotly_plot, show_link, link_text, validate,
686 image=image, filename=image_filename,
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/tools.py in mpl_to_plotly(fig, resize, strip_style, verbose)
463 if matplotlylib:
464 renderer = matplotlylib.PlotlyRenderer()
--> 465 matplotlylib.Exporter(renderer).run(fig)
466 if resize:
467 renderer.resize()
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/matplotlylib/mplexporter/exporter.py in run(self, fig)
47 import matplotlib.pyplot as plt
48 plt.close(fig)
---> 49 self.crawl_fig(fig)
50
51 @staticmethod
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/matplotlylib/mplexporter/exporter.py in crawl_fig(self, fig)
114 props=utils.get_figure_properties(fig)):
115 for ax in fig.axes:
--> 116 self.crawl_ax(ax)
117
118 def crawl_ax(self, ax):
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/matplotlylib/mplexporter/exporter.py in crawl_ax(self, ax)
119 """Crawl the axes and process all elements within"""
120 with self.renderer.draw_axes(ax=ax,
--> 121 props=utils.get_axes_properties(ax)):
122 for line in ax.lines:
123 self.draw_line(ax, line)
~/anaconda3/envs/mlapp/lib/python3.6/contextlib.py in __enter__(self)
79 def __enter__(self):
80 try:
---> 81 return next(self.gen)
82 except StopIteration:
83 raise RuntimeError("generator didn't yield") from None
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/matplotlylib/mplexporter/renderers/base.py in draw_axes(self, ax, props)
53 self._current_ax = ax
54 self._ax_props = props
---> 55 self.open_axes(ax=ax, props=props)
56 yield
57 self.close_axes(ax=ax)
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/matplotlylib/renderer.py in open_axes(self, ax, props)
163 x_bounds=self.mpl_x_bounds,
164 y_bounds=self.mpl_y_bounds)
--> 165 xaxis.update(mpl_xaxis)
166 yaxis.update(mpl_yaxis)
167 bottom_spine = mpltools.get_spine_visible(ax, 'bottom')
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/basedatatypes.py in update(self, dict1, **kwargs)
2854 BaseFigure._perform_update(self, kwargs)
2855 else:
-> 2856 BaseFigure._perform_update(self, dict1)
2857 BaseFigure._perform_update(self, kwargs)
2858
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/basedatatypes.py in _perform_update(plotly_obj, update_obj)
2138 else:
2139 # Assign non-compound value
-> 2140 plotly_obj[key] = val
2141
2142 elif isinstance(plotly_obj, tuple):
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/basedatatypes.py in __setitem__(self, prop, value)
2663 # ### Handle simple property ###
2664 else:
-> 2665 self._set_prop(prop, value)
2666
2667 # Handle non-scalar case
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/plotly/basedatatypes.py in _set_prop(self, prop, val)
2893 # ------------
2894 validator = self._validators.get(prop)
-> 2895 val = validator.validate_coerce(val)
2896
2897 # val is None
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/_plotly_utils/basevalidators.py in validate_coerce(self, v)
486 v = self.perform_replacemenet(v)
487 if not self.in_values(v):
--> 488 self.raise_invalid_val(v)
489 return v
490
~/anaconda3/envs/mlapp/lib/python3.6/site-packages/_plotly_utils/basevalidators.py in raise_invalid_val(self, v)
214 typ=type_str(v),
215 v=repr(v),
--> 216 valid_clr_desc=self.description()))
217
218 def raise_invalid_elements(self, invalid_els):
ValueError:
Invalid value of type 'builtins.bool' received for the 'tickmode' property of layout.xaxis
Received value: False
The 'tickmode' property is an enumeration that may be specified as:
- One of the following enumeration values:
['auto', 'linear', 'array']
I am preparing a PR request for discussion.