Hello,
I’m using Python 2.7.14, trying to convert a matplotlib plot to a plotly plot. When I use the mpl_to_plotly function on my figure, I get that the math module has no attribute ‘isclose’. math.isclose is only in python 3+, so I’m unsure why it is trying to use that. I installed using conda, which is on a 2.7 environment, and it installs 2.5.1. My current solution is to install from the conda channel, which installs 1.3.2, and downgrade matplotlib to 1.3.1, but I am missing out on some more recent features by doing this. How do I fix this?
<ipython-input-6-7b9d0f71f01a> in <module>()
4 daemon_stats[file[0]], sample_rate = get_daemon_stats_from_file(daemon_path + ''.join(file))
5
----> 6 plot_daemon_stats(daemon_stats, [f[0] for f in files])
<ipython-input-5-3fdcd3135153> in plot_daemon_stats(stats, node_names)
38 fig.tight_layout(pad=1, h_pad=3.5)
39
---> 40 plotly_fig = tls.mpl_to_plotly(fig)
41 update = dict(
42 layout=dict(showlegend=True)
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\tools.pyc in mpl_to_plotly(fig, resize, strip_style, verbose)
457 if matplotlylib:
458 renderer = matplotlylib.PlotlyRenderer()
--> 459 matplotlylib.Exporter(renderer).run(fig)
460 if resize:
461 renderer.resize()
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\mplexporter\exporter.pyc in run(self, fig)
47 import matplotlib.pyplot as plt
48 plt.close(fig)
---> 49 self.crawl_fig(fig)
50
51 @staticmethod
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\mplexporter\exporter.pyc 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):
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\mplexporter\exporter.pyc in crawl_ax(self, ax)
121 props=utils.get_axes_properties(ax)):
122 for line in ax.lines:
--> 123 self.draw_line(ax, line)
124 for text in ax.texts:
125 self.draw_text(ax, text)
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\mplexporter\exporter.pyc in draw_line(self, ax, line, force_trans)
194 markerstyle=markerstyle,
195 label=label,
--> 196 mplobj=line)
197
198 def draw_text(self, ax, text, force_trans=None, text_type=None):
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\renderer.pyc in draw_marked_line(self, **props)
348 color=color,
349 width=props['linestyle']['linewidth'],
--> 350 dash=mpltools.convert_dash(props['linestyle']['dasharray'])
351 )
352 if props['markerstyle']:
C:\Users\Cody\Miniconda2\lib\site-packages\plotly\matplotlylib\mpltools.pyc in convert_dash(mpl_dash)
66 # Catch the exception where the off length is zero, in case
67 # matplotlib 'solid' changes from '10,0' to 'N,0'
---> 68 if (math.isclose(float(dash_array[1]), 0.)):
69 return 'solid'
70
AttributeError: 'module' object has no attribute 'isclose'```