diff --git a/src/machinevisiontoolbox/ImageBlobs.py b/src/machinevisiontoolbox/ImageBlobs.py index fbc0c309..b1521c1f 100644 --- a/src/machinevisiontoolbox/ImageBlobs.py +++ b/src/machinevisiontoolbox/ImageBlobs.py @@ -2303,7 +2303,7 @@ def plot_aligned_box(self, *args: Any, **kwargs: Any) -> None: if not isinstance(boxes, list): boxes = [boxes] for box in boxes: - smb.plot_polygon(box[2], *args, close=True, **options) + smb.plot_polygon(box[2], close=True, **options) def plot_MEC(self, *args: Any, **kwargs: Any) -> None: """ @@ -2349,7 +2349,7 @@ def plot_MEC(self, *args: Any, **kwargs: Any) -> None: if not isinstance(mecs, list): mecs = [mecs] for mec in mecs: - smb.plot_circle(mec[2], mec[:2], *args, **options) + smb.plot_circle(mec[2], mec[:2], **options) def plot_MER(self, *args: Any, **kwargs: Any) -> None: """ @@ -2400,7 +2400,7 @@ def plot_MER(self, *args: Any, **kwargs: Any) -> None: box = np.array([[w, h], [w, -h], [-w, -h], [-w, h], [w, h]]).T / 2.0 T = SE2(float(mer[0]), float(mer[1]), float(np.radians(mer[4]))) box = np.asarray(T * box) - smb.plot_polygon(box[:2, :], *args, **options) + smb.plot_polygon(box[:2, :], **options) def label_image(self, image: Any = None) -> Any: """ diff --git a/tests/test_image_blobs.py b/tests/test_image_blobs.py index ef3c239c..1b0a08bd 100644 --- a/tests/test_image_blobs.py +++ b/tests/test_image_blobs.py @@ -890,6 +890,33 @@ def test_plot_aligned_box_ratio(self): def test_plot_aligned_box_kwargs(self): self._test_plot_adds("plot_aligned_box", self._lines, color="yellow") + # the format string is applied once, by mpl_styling: what each line looks like + _FMT_RESULTS = [ + # fmt, color, linestyle, marker + (None, "yellow", "-", "None"), + ("g", "g", "-", "None"), + ("r--", "r", "--", "None"), + ("--", "yellow", "--", "None"), + ("r:", "r", ":", "None"), + ("o", "yellow", "None", "o"), # markers only, as for plot() + ("r.", "r", "None", "."), + ("C1", "C1", "-", "None"), + ("orange", "orange", "-", "None"), + ] + + def test_polygon_and_circle_methods_apply_the_format_string_once(self): + for method in ("plot_aligned_box", "plot_MEC", "plot_MER"): + for fmt, color, linestyle, marker in self._FMT_RESULTS: + with self.subTest(method=method, fmt=fmt): + fig, ax = self._fresh_ax() + getattr(self.blobs1, method)(*([] if fmt is None else [fmt])) + line = ax.lines[0] + plt.close(fig) + self.assertEqual(line.get_color(), color) + self.assertEqual(line.get_linestyle(), linestyle) + self.assertEqual(line.get_marker(), marker) + self.assertEqual(line.get_linewidth(), 2) + # ------------------------------------------------------------------ # # plot_MEC (smb.plot_circle → 1 artist per blob) # ------------------------------------------------------------------ #