Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'pygame': 0.05; 'python': 0.08; '[0,': 0.09; 'graph': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '"python': 0.15; 'advice:': 0.16; 'pylab': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.16; 'from:addr:web.de': 0.23; 'horizontal': 0.23; 'code.': 0.26; 'import': 0.27; 'putting': 0.28; 'script': 0.28; 'example': 0.28; 'yield': 0.28; 'problem': 0.29; 'lines': 0.30; 'separately': 0.30; 'version': 0.31; 'values': 0.32; 'instead': 0.33; 'to:addr:python- list': 0.33; 'there': 0.33; 'points': 0.33; 'this.': 0.33; 'showing': 0.34; 'integer': 0.34; 'header:X-Complaints-To:1': 0.34; 'provide.': 0.36; 'two': 0.37; 'but': 0.37; 'received:org': 0.37; 'enough': 0.37; 'define': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'data': 0.40; 'achieve': 0.61; 'hope': 0.61; 'your': 0.61; 'square': 0.67; 'data)': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Plot square wave Date: Wed, 18 Jan 2012 17:09:28 +0100 Organization: None References: <03386c82-34e2-4ecd-a0fe-d109d1956fc0@m2g2000vbc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p50849e60.dip.t-dialin.net X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326902986 news.xs4all.nl 6958 [2001:888:2000:d::a6]:44265 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19090 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.