Python ProgrammingPython Programming

How to display background grid with Python Matplotlib?

Show background Grid:

import matplotlib.pyplot as plt

plt.grid(True, linewidth=0.5, color='#ff0000', linestyle='-')

#Plot a line graph
plt.plot([10, 20, 30, 40, 50])
# Add labels and title
plt.title("Interactive Plot")

The following is the output that will be obtained:

Show background grid