From: Felix S. <fel...@ui...> - 2010-08-16 11:34:01
|
Hi there, i got a question on how to best handle NaN values. I'm plotting 3 x-y curves into one plot (data comes from 3 files which are read and processed earlier in my code). Sometimes one of them has NaN-values at the y=0 point. If i just convert the NaN-values as everthing else: data_array.append(float(THENANVALUE)) the data array contains the nan and my values just fine. However if i then proceed to g.plot(...), i get a line 0: Bad data on line 1 error. What i would like to have, is a plot where the undefined lowest value is ignored and plotting starts at the first defined value. Is there a simple solution to this/ any suggestion? Thanks in advance for any answers! :-) Felix |
From: <bm...@ca...> - 2010-08-16 12:38:29
|
Quoting Felix Schueller <fel...@ui...>: > Hi there, > > i got a question on how to best handle NaN values. > > I'm plotting 3 x-y curves into one plot (data comes from 3 files which > are read and processed earlier in my code). > Sometimes one of them has NaN-values at the y=0 point. If i just convert > the NaN-values as everthing else: > > data_array.append(float(THENANVALUE)) > > the data array contains the nan and my values just fine. However if i > then proceed to g.plot(...), i get a > > line 0: Bad data on line 1 > > error. > > What i would like to have, is a plot where the undefined lowest value is > ignored and plotting starts at the first defined value. > > Is there a simple solution to this/ any suggestion? You need to remove the NaN before plotting. This is also the behavior I would want, not that things are plotted with undefined values without me knowing it. To obtain only the nonNan from a x,y plot: z = N.asarray([[x,y] for x,y in zip(a,b) if not math.isnan(x) ]) then plot z[:,0] and z[:,1] instead of x,y Probably there are nicer ways to do this filtering, a masked array perhaps. Benny > > Thanks in advance for any answers! :-) > > Felix > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > _______________________________________________ > Gnuplot-py-users mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |
From: Felix S. <fel...@ui...> - 2010-08-16 13:35:41
|
Hi Benny, thanks for your answer. The solution is nice enough for me and works just fine :-). Felix bm...@ca... wrote: > Quoting Felix Schueller<fel...@ui...>: > >> Hi there, >> >> i got a question on how to best handle NaN values. >> >> I'm plotting 3 x-y curves into one plot (data comes from 3 files which >> are read and processed earlier in my code). >> Sometimes one of them has NaN-values at the y=0 point. If i just convert >> the NaN-values as everthing else: >> >> data_array.append(float(THENANVALUE)) >> >> the data array contains the nan and my values just fine. However if i >> then proceed to g.plot(...), i get a >> >> line 0: Bad data on line 1 >> >> error. >> >> What i would like to have, is a plot where the undefined lowest value is >> ignored and plotting starts at the first defined value. >> >> Is there a simple solution to this/ any suggestion? > > You need to remove the NaN before plotting. This is also the behavior > I would want, not that things are plotted with undefined values > without me knowing it. > > To obtain only the nonNan from a x,y plot: > z = N.asarray([[x,y] for x,y in zip(a,b) if not math.isnan(x) ]) > then plot z[:,0] and z[:,1] instead of x,y > > Probably there are nicer ways to do this filtering, a masked array perhaps. > > Benny >> Thanks in advance for any answers! :-) >> >> Felix >> >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by >> >> Make an app they can't live without >> Enter the BlackBerry Developer Challenge >> http://p.sf.net/sfu/RIM-dev2dev >> _______________________________________________ >> Gnuplot-py-users mailing list >> Gnu...@li... >> https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users >> > > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > _______________________________________________ > Gnuplot-py-users mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users |