## Stem Plots

Stem plots draw a vertical line from (x, 0) to (x, y) for every (x, y) value as well as a marker at (x, y). Stem plots are used to denote discrete data and are popular for plotting filtering windows (see Listing 6-12).

Listing 6-12. A Stem Plot of Filter Windows from pylab import * N = [4, 8, 16, 64] for i, n in enumerate(N): subplot(2, 2, i+l)

stem(arange(n), hamming(n)) xticks(arange(o, n+1, n/4)) yticks([0, 0.5, 1]) xlim(-0.5, n+0.5) legend(['N=%d' % n])

Figure 6-14 shows the results of this listing. Figure 6-14. Stem plots of a Hamming window with different N values

In the preceding example, I've made use of the legend() function to denote the number of elements used in the plot, as I think it's clearer than a title. Notice that I had to supply a list to legend(['N=%d' % n]) (notice the brackets). Had I not supplied a list, the string 'N = %d' would have been split because legend() assumes a sequence of elements and assigns each one a plot line. I've also made use of the hamming() function to create a Hamming window, commonly used in filtering values.