Time for action – plotting the Bartlett window

The Bartlett window is a triangular smoothing window:

Time for action – plotting the Bartlett window
  1. Call the NumPy bartlett() function:
    window = np.bartlett(42)
  2. Plotting is easy with matplotlib:
    plt.plot(window)
    plt.show()

    The following is the Bartlett window, which is triangular, as expected:

    Time for action – plotting the Bartlett window

What just happened?

We plotted the Bartlett window with the NumPy bartlett() function.

Get NumPy : Beginner's Guide - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.