]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
fix : matplotlib stem() method call was modified from 3.0.3 to 3.1.0; adapting the...
authorjh777916 <juba.hamma@cea.fr>
Thu, 23 May 2024 09:45:55 +0000 (11:45 +0200)
committerjh777916 <juba.hamma@cea.fr>
Thu, 23 May 2024 09:45:55 +0000 (11:45 +0200)
tools/CurvePlot/src/python/views/StemView.py

index dd721b5153a5479150322cd300f9b168380a0ba4..995eaa4bf7179a83f4e752efaff44061f9f2e4c8 100644 (file)
 
 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 <Line2D>, stemlines<list(Line2D)>, baseline<Line2D> )
-    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()