From f11a36f3c397efc6b5509917a43f787916a06f2e Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 25 Nov 2020 11:20:49 +0200 Subject: [PATCH] Fix matplotlib 3.3.3 support --- .../plotlympl/mplexporter/renderers/base.py | 12 ++++++++++-- trains/utilities/plotlympl/mplexporter/utils.py | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/trains/utilities/plotlympl/mplexporter/renderers/base.py b/trains/utilities/plotlympl/mplexporter/renderers/base.py index 6bf5acb4..e955fdfe 100644 --- a/trains/utilities/plotlympl/mplexporter/renderers/base.py +++ b/trains/utilities/plotlympl/mplexporter/renderers/base.py @@ -18,11 +18,19 @@ class Renderer(object): @staticmethod def ax_has_xgrid(ax): - return bool(ax and ax.xaxis._gridOnMajor and ax.yaxis.get_gridlines()) + if not ax: + return False + _gridOnMajor = ax.xaxis._gridOnMajor if hasattr(ax.xaxis, '_gridOnMajor') \ + else ax.xaxis._major_tick_kw['gridOn'] + return bool(ax and _gridOnMajor and ax.yaxis.get_gridlines()) @staticmethod def ax_has_ygrid(ax): - return bool(ax and ax.yaxis._gridOnMajor and ax.yaxis.get_gridlines()) + if not ax: + return False + _gridOnMajor = ax.yaxis._gridOnMajor if hasattr(ax.yaxis, '_gridOnMajor') \ + else ax.yaxis._major_tick_kw['gridOn'] + return bool(ax and _gridOnMajor and ax.yaxis.get_gridlines()) @property def current_ax_zoomable(self): diff --git a/trains/utilities/plotlympl/mplexporter/utils.py b/trains/utilities/plotlympl/mplexporter/utils.py index 4059a6b6..261808fa 100644 --- a/trains/utilities/plotlympl/mplexporter/utils.py +++ b/trains/utilities/plotlympl/mplexporter/utils.py @@ -243,7 +243,8 @@ def get_axis_properties(axis): def get_grid_style(axis): gridlines = axis.get_gridlines() - if axis._gridOnMajor and len(gridlines) > 0: + _gridOnMajor = axis._gridOnMajor if hasattr(axis, '_gridOnMajor') else axis._major_tick_kw['gridOn'] + if _gridOnMajor and len(gridlines) > 0: color = export_color(gridlines[0].get_color()) alpha = gridlines[0].get_alpha() dasharray = get_dasharray(gridlines[0])