Thursday, September 29, 2016

Python: Matplotlib: Fill Example

Noteworthy:

matplotlib.pyplot.fill()


Command:

$ cat Downloads/fill_demo.py


Result:

"""
Simple demo of the fill function.
"""
import numpy as np
import matplotlib.pyplot as plt

plt.style.use('dark_background')

x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

plt.fill(x, y, 'r')
plt.grid(True)

plt.savefig("pyplot_fill.png")


Command:

$ python Downloads/fill_demo.py 
$ open pyplot_fill.png 


Graphical output: