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: diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index bf067b2abbfd..01b5826765e1 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -1,8 +1,7 @@ import platform import numpy as np - -from matplotlib.testing.decorators import image_comparison +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 +213,22 @@ def close_group(self, s): assert renderer.open_group('s') == "open_group overridden" assert renderer.close_group('s') == "close_group overridden" + + +@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 with the SimpleLineShadow path effect + line, = ax_test.plot(x, y, linewidth=5) + line.set_path_effects([path_effects.SimpleLineShadow( + 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)