Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XAxis' object has no attribute '_gridOnMajor #479

Closed
dmiller7115 opened this issue Nov 19, 2020 · 10 comments
Closed

XAxis' object has no attribute '_gridOnMajor #479

dmiller7115 opened this issue Nov 19, 2020 · 10 comments
Labels

Comments

@dmiller7115
Copy link

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'
@carlinmack
Copy link

There is a fix suggested here plotly/plotly.py#2913

carlinmack added a commit to carlinmack/mplexporter that referenced this issue Nov 19, 2020
@cliffckerr cliffckerr added the bug label Nov 20, 2020
@mpld3 mpld3 deleted a comment from keitayabu Nov 20, 2020
@cliffckerr
Copy link
Member

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.

@vladh
Copy link
Member

vladh commented Nov 20, 2020

Hey everyone, thank you for the report and for the information.

I've fixed this in mpld3/mplexporter@2f766e4...be8e3da

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!

@carlinmack
Copy link

thanks for testing! I didn't think about backwards compatibility, but glad to hear it works okay!

@vladh
Copy link
Member

vladh commented Nov 27, 2020

Fixed in release 0.5.2 in 4617a12 !

@tobiz
Copy link

tobiz commented May 27, 2022

As of 20220527 I still get this problem ('XAxis' object has no attribute '_gridOnMajor') with the example of dmiller7115 running kubuntu 21.10, python 3.9.7, matplotlib 3.5.2, plotly 5.8.0 - all python modules standard install. However the only difference is the line in issue is line 247, ie "if axis._gridOnMajor and len(gridlines) > 0:"

@vladh
Copy link
Member

vladh commented May 27, 2022

@tobiz Line 247 of what file? Doing an ack "_gridOnMajor" gives me nothing, hmm…

@tobiz
Copy link

tobiz commented May 27, 2022

Sorry!
This where it's installed in the VM; similar to the file ref in dmiller7115's install.
/usr/lib/python3/dist-packages/plotly/matplotlylib/mplexporter/utils.py

@vladh
Copy link
Member

vladh commented May 27, 2022

@tobiz It sounds like your problem is not with mpld3 but with "matplotlylib" — I'm not sure what that is, but it sounds like you have the wrong repo! :P

@bryevdv
Copy link

bryevdv commented May 27, 2022

wrong repo

Certainly but in the spirit of helpfulness it is probably worth mentioning the obvious conclusion, which is that the other project has vendored an old / out of date version of mpld3/mplexporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants