Python ProgrammingPython Programming

How to Plot a line graph with grayscale lines in Matplotlib?

Plot a line graph with grayscale lines:

import matplotlib.pyplot as plt

# Plot a line graph with grayscale lines	
plt.plot([5, 15], label='Rice', c='0.15')
plt.plot([3, 6], label='Oil', c='0.35')
plt.plot([8.0010, 14.2], label='Wheat',  c='0.55')
plt.plot([1.95412, 6.98547, 5.41411, 5.99, 7.9999], label='Coffee',  c='0.85')

# Add labels and title
plt.title("Interactive Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")

plt.legend()
plt.show()

The following is the output that will be obtained:


Plot a line graph with grayscale lines