I'd like to create a plot like the one below with python/pandas/matplotlib. The upper clip is no problem, but I haven't been able to get a plot like the lower clip to work. I can do it in gnuplot where the equivalent plot style is 'with impulses'. Is this possible with matplotlib? If it is not possible with matplotlib is there another python graphics package that would work?
The easiest way to create such a plot is to use pyplot.stem
.
An example can be found here.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0.1, 6*np.pi, 50)
plt.stem(x, np.cos(x)+1, linefmt='g-', markerfmt=' ')
plt.stem(x, -np.sin(x)-1, linefmt='r-', markerfmt=' ', basefmt="gray")
plt.show()
Another option is to use pyplot.vlines
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With