From 26e4ea941256d5c4016b52dd8faaa85b794275d0 Mon Sep 17 00:00:00 2001 From: jh777916 Date: Thu, 23 May 2024 11:45:55 +0200 Subject: [PATCH] fix : matplotlib stem() method call was modified from 3.0.3 to 3.1.0; adapting the call to stem() method to keep backward compatibility --- tools/CurvePlot/src/python/views/StemView.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/CurvePlot/src/python/views/StemView.py b/tools/CurvePlot/src/python/views/StemView.py index dd721b515..995eaa4bf 100644 --- a/tools/CurvePlot/src/python/views/StemView.py +++ b/tools/CurvePlot/src/python/views/StemView.py @@ -19,6 +19,11 @@ from .PlotView import PlotView from .utils import Logger +# Matplotlib stem() function evolved from 3.0.3 to 3.1.0 : update of the returned StemContainer +# The old implementation of StemView class is kept to ensure backwards compatibility +# with Salome 9.9.0, which uses matplotlib v3.0.3 +import matplotlib +from packaging import version class StemView(PlotView): _PICKER_PRECISION = 10 #pts @@ -32,8 +37,13 @@ class StemView(PlotView): d = self._model.getTable().getData() # stem returns a StemContainer : (markerline , stemlines, baseline ) - self._mplArtist = self._mplAxes.stem(d[:, x_idx], d[:, y_idx], label=m._title,\ - linefmt='b-', markerfmt='_', basefmt=' ') + if version.parse(matplotlib.__version__) < version.parse("3.1.0"): + self._mplArtist = self._mplAxes.stem(d[:, x_idx], d[:, y_idx], label=m._title,\ + linefmt='b-', markerfmt='_', basefmt=' ') + else: + self._mplArtist = self._mplAxes.stem(d[:, x_idx], d[:, y_idx], label=m._title,\ + linefmt='b-', markerfmt='_', basefmt=' ', + use_line_collection=False) self._initialLineWidth = self._mplArtist[0].get_linewidth() self._initialZOrder = self._mplArtist[0].get_zorder() -- 2.39.2