contribution: cstem -- stemplot for complex impulse vectors


I needed to use "stem" for complex impulse vectors and found that it
was too much work to make it behave. I therefore wrote "cstem" which
is intended for complex impulse vectors. It takes x (optional) and z
vectors, and a small number of special keyword parameters -- remaining
keywords are handed off to "plot" during plotting.

I've tried making it as similar to "stem" as I found useful, but it is
not a drop-in replacement. It is written as a function, not an axis
method, but if found useful to others, changing it over should not be

The code has ReST docstring including example of use:

    >>> z = np.random.uniform(size=10) + 1j*np.random.uniform(size=10)
    >>> cstem(z)

    or, using explicit x axis and keeping handles

    >>> x = np.r_[1:3:10j]
    >>> r_mark, i_mark, r_line, i_line, baseline = cstem(x, z)

License: anything BSD-ish that is broadly used in matplotlib already.

Enjoy! Comments/suggestions welcome. (3.94 KB)


Tom Grydeland