Stem plot?

299 views
Skip to first unread message

chrys...@free.fr

unread,
Apr 8, 2015, 4:51:49 AM4/8/15
to pyqt...@googlegroups.com
Hello,

I would like to make this kind of graph (not linking each data points but draw a vertical line from 0 to y) using pyqtgraph but I can't find a way to do this: http://matplotlib.org/examples/pylab_examples/stem_plot.html

Does anybody know how I can do this?

Thank you

Luke Campagnola

unread,
Apr 8, 2015, 9:20:43 AM4/8/15
to pyqt...@googlegroups.com
It should be very simple to build this from a PlotCurveItem using connect="pairs" to draw the lines and a ScatterPlotItem to draw the points. 

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/f4471b50-dbdc-492a-95b7-ef831aec1ee8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chrys...@free.fr

unread,
Apr 9, 2015, 11:07:51 AM4/9/15
to pyqt...@googlegroups.com
Thanks for pointing this out,

I used this function to draw the graph (I didn't wanted the points):

def plot_centroid(plot, x, y, **kwargs):
return plot.plot(x=np.repeat(x, 2), y=np.dstack((np.zeros(y.shape[0]), y)).flatten(), connect='pairs', **kwargs)

Not sure it's the most efficient way to do it, but it works

----- Mail original -----
De: "Luke Campagnola" <luke.ca...@gmail.com>
À: pyqt...@googlegroups.com
Envoyé: Mercredi 8 Avril 2015 15:20:12
Objet: Re: [pyqtgraph] Stem plot?
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/yD2sO6Ytotw/unsubscribe .
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET-MxH5UpLaXO0er8dR8qigBnYxKEcNLzPJJm4W9-62Ljg%40mail.gmail.com .
Reply all
Reply to author
Forward
0 new messages