Skip to content

Commit d91dd04

Browse files
authored
Merge pull request #447 from nschloe/mpl3.3.3-fix
fix for mpl 3.3.3
2 parents 3c1e08e + da9d766 commit d91dd04

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = tikzplotlib
3-
version = 0.9.4
3+
version = 0.9.5
44
author = Nico Schlömer
55
author_email = [email protected]
66
description = Convert matplotlib figures into TikZ/PGFPlots

test/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def assert_equality(
4444
this_dir = os.path.dirname(os.path.abspath(__file__))
4545
with open(os.path.join(this_dir, filename), encoding="utf-8") as f:
4646
reference = f.read()
47-
assert reference == code, _unidiff_output(reference, code)
47+
assert reference == code, filename + "\n" + _unidiff_output(reference, code)
4848

4949
if assert_compilation:
5050
plot()

tikzplotlib/_axes.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,23 @@ def _grid(self, obj, data):
295295
# Don't use get_{x,y}gridlines for gridlines; see discussion on
296296
# <http://sourceforge.net/p/matplotlib/mailman/message/25169234/> Coordinate of
297297
# the lines are entirely meaningless, but styles (colors,...) are respected.
298-
if obj.xaxis._gridOnMajor:
298+
299+
try:
300+
# mpl 3.3.3+
301+
# <https://github.com/matplotlib/matplotlib/pull/18769>
302+
has_major_xgrid = obj.xaxis._major_tick_kw["gridOn"]
303+
has_minor_xgrid = obj.xaxis._minor_tick_kw["gridOn"]
304+
has_major_ygrid = obj.yaxis._major_tick_kw["gridOn"]
305+
has_minor_ygrid = obj.yaxis._minor_tick_kw["gridOn"]
306+
except KeyError:
307+
has_major_xgrid = obj.xaxis._gridOnMajor
308+
has_minor_xgrid = obj.xaxis._gridOnMinor
309+
has_major_ygrid = obj.yaxis._gridOnMajor
310+
has_minor_ygrid = obj.yaxis._gridOnMinor
311+
312+
if has_major_xgrid:
299313
self.axis_options.append("xmajorgrids")
300-
if obj.xaxis._gridOnMinor:
314+
if has_minor_xgrid:
301315
self.axis_options.append("xminorgrids")
302316

303317
xlines = obj.get_xgridlines()
@@ -307,9 +321,9 @@ def _grid(self, obj, data):
307321
if col != "black":
308322
self.axis_options.append(f"x grid style={{{col}}}")
309323

310-
if obj.yaxis._gridOnMajor:
324+
if has_major_ygrid:
311325
self.axis_options.append("ymajorgrids")
312-
if obj.yaxis._gridOnMinor:
326+
if has_minor_ygrid:
313327
self.axis_options.append("yminorgrids")
314328

315329
ylines = obj.get_ygridlines()

0 commit comments

Comments
 (0)