]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
fix : matplotlib xaxis._gridOnMajor was modified from matplotlib v3.2.0 to 3.3.0... jha/CurvePlot_barplot_stemplot_9_12_0
authorjh777916 <juba.hamma@cea.fr>
Thu, 23 May 2024 12:10:48 +0000 (14:10 +0200)
committerjh777916 <juba.hamma@cea.fr>
Thu, 23 May 2024 12:10:48 +0000 (14:10 +0200)
tools/CurvePlot/src/python/views/XYView.py

index 3f60df5ffb35c641b6cedddf791e71b414c109c4..773e655e2c6ff4f9090cb5bc65f978fcb2bbda65 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+# Matplotlib xaxis._gridOnMajor is deprecated since matplotlib v3.3.0
+# The old implementation of XYView class is kept to ensure backwards compatibility
+# with Salome 9.9.0, which uses matplotlib v3.0.3
+import matplotlib
+from packaging import version
+
 import matplotlib.pyplot as plt
 import matplotlib.colors as colors
 from matplotlib.patches import Rectangle
@@ -610,7 +616,11 @@ class XYView(View):
     dlg.titleEdit.setText(self._mplAxes.get_title())
     dlg.axisXTitleEdit.setText(self._mplAxes.get_xlabel())
     dlg.axisYTitleEdit.setText(self._mplAxes.get_ylabel())
-    dlg.gridCheckBox.setChecked(self._mplAxes.xaxis._gridOnMajor)  # could not find a relevant API to check this
+    # could not find a relevant API to check this
+    if version.parse(matplotlib.__version__) < version.parse("3.3.0"):
+      dlg.gridCheckBox.setChecked(self._mplAxes.xaxis._gridOnMajor)
+    else :
+      dlg.gridCheckBox.setChecked(self._mplAxes.xaxis._major_tick_kw['gridOn'])
     dlg.axisXSciCheckBox.setChecked(self._axisXSciNotation)
     dlg.axisYSciCheckBox.setChecked(self._axisYSciNotation)
     xmin, xmax = self._mplAxes.get_xlim()