From: Emmanuel <emm...@fa...> - 2007-05-03 19:12:19
|
With gnuplot one can do a plot like that : http://www.deqnotes.net/gnuplot/images/impulses.png It is using option "with impulse". Is there an equivalent in matplotlib? |
From: Antonino I. <tri...@gm...> - 2007-05-11 16:25:07
|
Fowarding to the list ... ---------- Forwarded message ---------- From: Antonino Ingargiola <tri...@gm...> Date: 4-mag-2007 11.12 Subject: Re: [Matplotlib-users] matplolib equivalent of gnuplot's impulse To: Emmanuel <emm...@fa...> Hi, On 5/3/07, Emmanuel <emm...@fa...> wrote: > With gnuplot one can do a plot like that : > > http://www.deqnotes.net/gnuplot/images/impulses.png > > It is using option "with impulse". > Is there an equivalent in matplotlib? Maybe not directly as a "plot style". But... If you need to fill the curve with a color you can see this example: http://matplotlib.sourceforge.net/screenshots/fill_demo.py If you need the "bar" itself you can use the bar() function. If you need impulses composed by just "a line" you can use this function: def impulse(X, Y, color='blue', **kwargs): """Plot an "impulse" graph similar to the gnuplot 'impulse' function.""" if len(X) != len(Y): raise ValueError, "X and Y data must be of the same length." ax = gca() for x, y in zip(X, Y): ax.plot([x, x], [0, y], color=color, **kwargs) You can pass to it any plot() keyword-argument to customize line style. Cheers, ~ Antonio |
From: John H. <jd...@gm...> - 2007-05-11 16:49:03
|
On 5/3/07, Emmanuel <emm...@fa...> wrote: > With gnuplot one can do a plot like that : > > http://www.deqnotes.net/gnuplot/images/impulses.png > > It is using option "with impulse". > Is there an equivalent in matplotlib? In [5]: t = arange(0.0, 2.0, 0.05) In [6]: s = sin(2*pi*t) In [7]: vlines(t, 0, s) Out[7]: <matplotlib.collections |
From: Antonino I. <tri...@gm...> - 2007-05-11 17:05:13
|
2007/5/11, John Hunter <jd...@gm...>: > On 5/3/07, Emmanuel <emm...@fa...> wrote: > > With gnuplot one can do a plot like that : > > > > http://www.deqnotes.net/gnuplot/images/impulses.png > > > > It is using option "with impulse". > > Is there an equivalent in matplotlib? > > > In [5]: t = arange(0.0, 2.0, 0.05) > > In [6]: s = sin(2*pi*t) > > In [7]: vlines(t, 0, s) > Out[7]: <matplotlib.collections You are right! Very nice :-). ~ Antonio |