Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly mpl_to_plotly error: 'Spine' object has no attribute 'is_frame_like'

I have a matplotlib figure that I want to convert to plotly

import matplotlib.pyplot as plt
from plotly.tools import mpl_to_plotly

fig = plt.figure()

## Lots of code to create my figure ##

plotly_fig = mpl_to_plotly(fig)

The error I get is AttributeError: 'Spine' object has no attribute 'is_frame_like'

I thought the function was pretty straightforward, how do I fix this?

like image 297
Aravind Mantravadi Avatar asked Oct 12 '25 08:10

Aravind Mantravadi


1 Answers

This error occurs is because it calls a removed function in Matplotlib.

Warning (from warnings module):
  File "C:\Program Files\Python36\lib\site-packages\plotly\matplotlylib\mpltools.py", line 368
    spine_frame_like = spine.is_frame_like()
MatplotlibDeprecationWarning: 
The is_frame_like function was deprecated in Matplotlib 3.1 and will be removed in 3.3.

In the latest commit of plotly packages/python/plotly/plotly/matplotlylib/mpltools.py line 368, it still calls is_frame_like() function. There is already an issue tracking this. You may need choose to downgrade Matplotlib if you still want to use mpl_to_plotly() function.

nicolaskruchten, a member of the Plotly organization, says in that issue

Indeed, our matplotlib conversion utility should be considered deprecated at this point as it isn’t being actively maintained to track deprecations and changes in matplotlib itself so it works best with older versions of matplotlib. I should update the docstrings accordingly.

In the meantime, he claims

That said, if someone wants to work on it to bring it back up to date I’d be happy to work with them to integrate the changes :)

like image 59
Ynjxsjmh Avatar answered Oct 16 '25 07:10

Ynjxsjmh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!