Mpld3: XAxis' object has no attribute '_gridOnMajor

Created on 19 Nov 2020  路  5Comments  路  Source: mpld3/mpld3

Hello, matplotlib recently merged a change that removed provide variables from Axis: matplotlib/matplotlib#18769.

I hit this bug when converting matplotlib to html.

  • matplotlib>=3.3.3
  • mpld3==0.5.1

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'
bug

Most helpful comment

There is a fix suggested here https://github.com/plotly/plotly.py/issues/2913

All 5 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dansteingart picture dansteingart  路  31Comments

andreatramacere picture andreatramacere  路  8Comments

arnaudrenaud picture arnaudrenaud  路  4Comments

ledmonster picture ledmonster  路  4Comments

pranet picture pranet  路  6Comments