tags:

views:

49

answers:

2

Hi, in python, I would like to use:
from pylab import *
Then use plot provided in this module. However, the curves I plot were not what I want:
Say two lists:
x = [1, 2, 3, 4]
y = [1.4, 5.6, 6, 3.5]
and I am after a plot method that can plot the following chart:
Plot a line that joins the points: (1, 0) and (1, 1.4)
Plot a line that joins the points: (2, 0) and (2, 5.6)
Plot a line that joins the points: (3, 0) and (3, 6)
Plot a line that joins the points: (4, 0) and (4, 3.5)
...
i.e.: it should plot a spectra like graphs, such as plot(x, type='h') in R. I suppose the plot method I use just joins all the points by lines. So, for my purpose, which methods to choose please? thanks!!

+1  A: 

Do you mean a bar chart? If so, just use the bar function:

bar(x, y)
Liquid_Fire
@Liquid_Fire: No, not at all...if you could help to draw what I described, then you could see:) thank you!!
ladyfafa
+3  A: 

Maybe you want just vertical lines? You could use vlines(x, [0], y). See this example

You could also have a look at this page (screenshots) to help you select the right function.

Rod
I was just about to add that to my answer... Beat me to it! If he just wants the vertical lines (and no marker at the end of them) then `vlines` is better than `stem`. I think I'll delete mine to avoid confusion...
Joe Kington
@Rod: thank you !! that's what I want, I've searching for one hour now I got it, many thanks!~
ladyfafa