-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
Hello, matplotlib recently merged a change that removed provide variables from Axis: matplotlib/matplotlib#18769. There are at least 2 places in plotly code that reference these variables:
if axis._gridOnMajor and len(gridlines) > 0: |
plotly.py/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/base.py
Line 21 in 65625d4
return bool(ax and ax.xaxis._gridOnMajor and ax.yaxis.get_gridlines()) |
plotly.py/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/base.py
Line 25 in 65625d4
return bool(ax and ax.yaxis._gridOnMajor and ax.yaxis.get_gridlines()) |
In particular I hit this bug when converting matplotlib to pyplot.
- matplotlib>=3.3.3
- plotly>=4.12.0
Repro:
import plotly
import matplotlib.pyplot as plt
fig = plt.figure(1)
ax = plt.plot([1,2,3])
plotly.tools.mpl_to_plotly(fig)
results in
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-c2ca21d8fe91> in <module>()
1 fig = plt.figure(1)
2 ax = plt.plot([1,2,3])
----> 3 plotly.tools.mpl_to_plotly(fig)
6 frames
/usr/local/lib/python3.6/dist-packages/plotly/matplotlylib/mplexporter/utils.py in get_grid_style(axis)
244 def get_grid_style(axis):
245 gridlines = axis.get_gridlines()
--> 246 if axis._gridOnMajor and len(gridlines) > 0:
247 color = export_color(gridlines[0].get_color())
248 alpha = gridlines[0].get_alpha()
AttributeError: 'XAxis' object has no attribute '_gridOnMajor'
FWIW, i think the fix is to replace these calls with _major_tick_kw['gridOn']
.
Thank you,
Tim
edridgedsouza, xanderdunn, cifkao, sjdonado, phant0mon and 2 more
Metadata
Metadata
Assignees
Labels
No labels