From: jh777916 Date: Thu, 23 May 2024 12:10:48 +0000 (+0200) Subject: fix : matplotlib xaxis._gridOnMajor was modified from matplotlib v3.2.0 to 3.3.0... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b54e417f60;p=modules%2Fgui.git fix : matplotlib xaxis._gridOnMajor was modified from matplotlib v3.2.0 to 3.3.0; adapting the call to the attribute to keep backward compatibility --- diff --git a/tools/CurvePlot/src/python/views/XYView.py b/tools/CurvePlot/src/python/views/XYView.py index 3f60df5ff..773e655e2 100644 --- a/tools/CurvePlot/src/python/views/XYView.py +++ b/tools/CurvePlot/src/python/views/XYView.py @@ -17,6 +17,12 @@ # 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()