How to provide shadow effect in a Plot using path_effect attribute in Matplotlib

Machine LearningServer Side ProgrammingProgramming

In order to provide path effects like shadow effect in a plot or a graph, we can use the path_effect attribute.

For example, let’s see how we can use the path_effect attribute in Matplotlib add a shadow effect to a sigmoid function.

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patheffects import PathPatchEffect, SimpleLineShadow, Normal

Now let us define the size of the figure and plot the sigmoid function,'seaborn-deep')

Let us define the datapoints for the plot,

x = np.linspace(-10, 10, 50)
y = 1+ np.exp(-x))

Let us define the shadow property in the plot,

plt.plot(x, y, linewidth=8, color='blue', path_effects=
[SimpleLineShadow(), Normal()])
#Show the Plot


Published on 23-Feb-2021 10:52:28