Plot seems weird

Yigit Turgut y.turgut at gmail.com
Sun Dec 25 13:27:20 EST 2011


On Dec 25, 7:06 pm, Rick Johnson <rantingrickjohn... at gmail.com> wrote:
> On Dec 25, 9:33 am, Yigit Turgut <y.tur... at gmail.com> wrote:
> > Hi all,
>
> > I have a text file as following;
>
> > 0.200047        0.000000
> > 0.200053        0.160000
> > 0.200059        0.000000
> > 0.200065        0.080000
> > 0.200072        0.000000
> > 0.200078        0.160000
>
> > And I am trying to plot it with ;
>
> > filenames = sys.argv[1:]
> > if len(filenames) == 0:
> >     filenames = [sys.stdin]
> > for filename in filenames:
> >     t,y1 = numpy.genfromtxt(filename, unpack=True)
> >     pyplot.plot(t,y1)
> >     pyplot.show()
>
> > But graph seems weird, not as it supposed to be. Any ideas ?
>
> Interesting. Of course "weird" leaves a LOT to be desired. On a scale
> of 1-10, how "weird" is the result?

I apply a 1Khz test signal just to see if things run smoothly, but I
see spikes at lower and higher ends (logic 0,1) where I should see a
clean rectangle pwm signal. By the look of it I say weirdness is
around 3/10.

>
> But seriously. Have you tried debugging yet? If not, test these
> points:
Yes I double checked it, there seems to be nothing wrong in debug.

>  * What is the value of "filenames" BEFORE the loop?

Filename is argument 1 of the startup action.

>  * What is the value of "t" and "y1" for each iteration?

I test with both low and mid frequency signals (50Hz - 1Khz), same
inconsistency.

>
> Also observe this wonderful phenomenon:
>
> py> [] or [1,2,3]
> [1, 2, 3]
> py> [] or None or '' or () or {} or [1,2,3] or "1,2,3"
> [1, 2, 3]

Beautiful. I convert my arrays to string before writing to file.
Original post contains a fragment of the whole file. Data is
fluctuating, not a linear behavior.




More information about the Python-list mailing list