From 6f2335c28dfa25de407aafe9e7e8d4e51a183230 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Thu, 14 Dec 2023 13:36:07 +0100 Subject: [PATCH] replace addShape's linebgcolor argument with gapcolor --- src/silx/gui/plot/PlotInteraction.py | 2 +- src/silx/gui/plot/PlotWidget.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/silx/gui/plot/PlotInteraction.py b/src/silx/gui/plot/PlotInteraction.py index f7e8503c86..d19bb6dd11 100644 --- a/src/silx/gui/plot/PlotInteraction.py +++ b/src/silx/gui/plot/PlotInteraction.py @@ -134,7 +134,7 @@ def setSelectionArea(self, points, fill, color, name="", shape="polygon"): shape=shape, fill=fill, color=color, - linebgcolor=color2, + gapcolor=color2, linestyle="--", overlay=True, ) diff --git a/src/silx/gui/plot/PlotWidget.py b/src/silx/gui/plot/PlotWidget.py index d451d9faf4..a01ca48037 100755 --- a/src/silx/gui/plot/PlotWidget.py +++ b/src/silx/gui/plot/PlotWidget.py @@ -70,6 +70,7 @@ from .. import qt from ._utils.panzoom import ViewConstraints from ...gui.plot._utils.dtime_ticklayout import timestamp +from ...utils.deprecation import deprecated_warning """ @@ -1643,7 +1644,8 @@ def addShape( z=None, linestyle="-", linewidth=1.0, - linebgcolor=None, + linebgcolor="deprecated", + gapcolor=None, ): """Add an item (i.e. a shape) to the plot. @@ -1680,7 +1682,7 @@ def addShape( - ':' dotted line :param float linewidth: Width of the line. Only relevant for line markers where X or Y is None. - :param str linebgcolor: Background color of the line, e.g., 'blue', 'b', + :param str gapcolor: Gap color of the line, e.g., 'blue', 'b', '#FF0000'. It is used to draw dotted line using a second color. :returns: The shape item """ @@ -1705,7 +1707,15 @@ def addShape( item.setPoints(numpy.array((xdata, ydata)).T) item.setLineStyle(linestyle) item.setLineWidth(linewidth) - item.setLineGapColor(linebgcolor) + if linebgcolor != "deprecated": + deprecated_warning( + type_="Argument", + name="linebgcolor", + replacement="gapcolor", + since_version="2.0.0", + ) + gapcolor = linebgcolor if gapcolor is None else gapcolor + item.setLineGapColor(gapcolor) self.addItem(item)