Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19090
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Plot square wave |
| Date | 2012-01-18 17:09 +0100 |
| Organization | None |
| References | <03386c82-34e2-4ecd-a0fe-d109d1956fc0@m2g2000vbc.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4836.1326902986.27778.python-list@python.org> (permalink) |
Yigit Turgut wrote: > Problem is I get a sawtooth instead of a square wave. I know that I > need to define points between 0,1,2 time integer values to achieve > this. But I hope there is a python trick that will yield this > time,data plot to a square wave? There is no "Python trick", pylab is showing the data you provide. To get a square wave you need two y values per x value, for example import pylab time = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4] data = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1] pylab.plot(time, data) pylab.ylim(-.1, 1.1) # so you see the horizontal lines of the graph pylab.xlim(-.1, 4.1) pylab.show() A general advice: try the individual aspects of your script (plotting, pygame flicker, data i/o) separately to make sure you understand them well enough before putting them together in the final version of your code.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Plot square wave Yigit Turgut <y.turgut@gmail.com> - 2012-01-18 06:41 -0800 Re: Plot square wave Peter Otten <__peter__@web.de> - 2012-01-18 17:09 +0100
csiph-web