Hello, matplotlib recently merged a change that removed provide variables from Axis: matplotlib/matplotlib#18769.
I hit this bug when converting matplotlib to html.
Reproduce by:
import mpld3
import matplotlib.pyplot as plt
fig = plt.figure(1)
ax = plt.plot([1,2,3])
mpld3.fig_to_html(fig)
Results in
~/venv/lib/python3.7/site-packages/mpld3/mplexporter/utils.py in get_grid_style(axis)
261 def get_grid_style(axis):
262 gridlines = axis.get_gridlines()
--> 263 if axis._gridOnMajor and len(gridlines) > 0:
264 color = export_color(gridlines[0].get_color())
265 alpha = gridlines[0].get_alpha()
AttributeError: 'XAxis' object has no attribute '_gridOnMajor'
There is a fix suggested here https://github.com/plotly/plotly.py/issues/2913
Thank you @dmiller7115 and @carlinmack -- we'll try to get this fixed in the next few days. Main thing to check is that the fix doesn't break anything for previous version of Matplotlib.
Hey everyone, thank you for the report and for the information.
I've fixed this in https://github.com/mpld3/mplexporter/compare/2f766e439b9d91ab4d4682245a2360bc1e5c2bb5...be8e3da62c81fea15a0107f3ae96ba16fc2cc9f
I've confirmed that the fix suggested by @carlinmack works for matplotlib versions 3.3.3, 3.2.1 and 2.2.5.
The fix will be available as soon as I push out the new version, which will be ASAP.
Let me know if you encounter any problems!
thanks for testing! I didn't think about backwards compatibility, but glad to hear it works okay!
Fixed in release 0.5.2 in https://github.com/mpld3/mpld3/commit/4617a12d7d0cafd636e66bc65a709e2aab22c0e6 !
Most helpful comment
There is a fix suggested here https://github.com/plotly/plotly.py/issues/2913