From ca7418476ac4891b586ed6b75fa1a95b0ba736f5 Mon Sep 17 00:00:00 2001 From: Aman Nijjar Date: Thu, 12 Sep 2024 18:10:50 -0700 Subject: [PATCH 1/3] Replaced get_forground() in patheffects.py with get_rgb() --- lib/matplotlib/patheffects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/patheffects.py b/lib/matplotlib/patheffects.py index e7a0138bd750..1115e1d37503 100644 --- a/lib/matplotlib/patheffects.py +++ b/lib/matplotlib/patheffects.py @@ -325,7 +325,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace): gc0.copy_properties(gc) if self._shadow_color is None: - r, g, b = (gc0.get_foreground() or (1., 1., 1.))[:3] + r, g, b = (gc0.get_rgb() or (1., 1., 1.))[:3] # Scale the colors by a factor to improve the shadow effect. shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho) else: From 0d3000fd0f16df12078b262d4b844028a328a66b Mon Sep 17 00:00:00 2001 From: Aman Nijjar Date: Sun, 20 Oct 2024 20:44:28 -0700 Subject: [PATCH 2/3] Built a unit test to test simpleLineShadow_plot --- lib/matplotlib/tests/test_patheffects.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index bf067b2abbfd..f6fbd320d6d2 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -1,8 +1,8 @@ import platform import numpy as np - -from matplotlib.testing.decorators import image_comparison +import pytest +from matplotlib.testing.decorators import image_comparison, check_figures_equal import matplotlib.pyplot as plt import matplotlib.patheffects as path_effects from matplotlib.path import Path @@ -214,3 +214,23 @@ def close_group(self, s): assert renderer.open_group('s') == "open_group overridden" assert renderer.close_group('s') == "close_group overridden" + + +@pytest.mark.xfail(reason="figures are not meant to be equal") +@check_figures_equal() +def test_simpleLineShadow_plot(fig_test, fig_ref): + # Create the plots + ax_ref = fig_ref.add_subplot() + ax_test = fig_test.add_subplot() + + # Generate Gaussian distribution data + x = np.linspace(-5, 5, 500) + y = np.exp(-x**2) + + # Plot the Gaussian line simply + ax_ref.plot(x, y, linewidth=5, color='blue') + + # Plot the Gaussian line with the SimpleLineShadow path effect + line, = ax_test.plot(x, y, linewidth=5, color='blue') + line.set_path_effects([path_effects.SimpleLineShadow( + offset=(0, 0), shadow_color=None, rho=0.6)]) From f84c8a1a68775bf9342289dd61c0307c9f3d7df4 Mon Sep 17 00:00:00 2001 From: Aman Nijjar Date: Mon, 4 Nov 2024 21:17:18 -0800 Subject: [PATCH 3/3] fixed test_simpleLineShadow_plot --- lib/matplotlib/tests/test_patheffects.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index f6fbd320d6d2..01b5826765e1 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -1,7 +1,6 @@ import platform import numpy as np -import pytest from matplotlib.testing.decorators import image_comparison, check_figures_equal import matplotlib.pyplot as plt import matplotlib.patheffects as path_effects @@ -216,7 +215,6 @@ def close_group(self, s): assert renderer.close_group('s') == "close_group overridden" -@pytest.mark.xfail(reason="figures are not meant to be equal") @check_figures_equal() def test_simpleLineShadow_plot(fig_test, fig_ref): # Create the plots @@ -227,10 +225,10 @@ def test_simpleLineShadow_plot(fig_test, fig_ref): x = np.linspace(-5, 5, 500) y = np.exp(-x**2) - # Plot the Gaussian line simply - ax_ref.plot(x, y, linewidth=5, color='blue') - # Plot the Gaussian line with the SimpleLineShadow path effect - line, = ax_test.plot(x, y, linewidth=5, color='blue') + line, = ax_test.plot(x, y, linewidth=5) line.set_path_effects([path_effects.SimpleLineShadow( - offset=(0, 0), shadow_color=None, rho=0.6)]) + offset=(0, 0), shadow_color='blue', rho=0.5)]) + + # Plot the Gaussian line simply + ax_ref.plot(x, y, linewidth=5, color='blue', alpha=0.3)