From: jh777916 Date: Thu, 23 May 2024 09:45:55 +0000 (+0200) Subject: fix : matplotlib stem() method call was modified from 3.0.3 to 3.1.0; adapting the... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=26e4ea9412;p=modules%2Fgui.git 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 --- 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()