From 5ee6425b4fea67815ae61fb29a2751ff1ea7b125 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 7 Apr 2021 18:38:58 +0300 Subject: [PATCH] Fix remove deprecation warning with matplotlib 3.1 --- clearml/utilities/plotlympl/mpltools.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/clearml/utilities/plotlympl/mpltools.py b/clearml/utilities/plotlympl/mpltools.py index a55647db..d3d69825 100644 --- a/clearml/utilities/plotlympl/mpltools.py +++ b/clearml/utilities/plotlympl/mpltools.py @@ -8,12 +8,27 @@ import math import warnings import matplotlib.dates +from matplotlib import __version__ as matplotlib_version try: from matplotlib.patches import FancyBboxPatch except ImportError: FancyBboxPatch = None +def check_maplotlib_max_version(ver_maj, ver_min): + """ + return True if check_maplotlib_version is lower than specified version + """ + parts = matplotlib_version.split('.') + if not parts: + return False + if parts[0] < str(ver_maj): + return True + if len(parts) > 1 and parts[1] < str(ver_min): + return True + return False + + def check_bar_match(old_bar, new_bar): """Check if two bars belong in the same collection (bar chart). @@ -368,7 +383,10 @@ def get_spine_visible(ax, spine_key): """Return some spine parameters for the spine, `spine_key`.""" spine = ax.spines[spine_key] ax_frame_on = ax.get_frame_on() - spine_frame_like = spine.is_frame_like() if hasattr(spine, 'is_frame_like') else True + if check_maplotlib_max_version('3', '1'): + spine_frame_like = spine.is_frame_like() if hasattr(spine, 'is_frame_like') else True + else: + spine_frame_like = True if not spine.get_visible(): return False elif not spine._edgecolor[-1]: # user's may have set edgecolor alpha==0