Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Richard Langley <lang@un...>  20131208 13:49:41

I have a file of x,y real data pairs with the values to 9 digits of precision. When I use gnuplot to plot the data directly using, say: plot 'HHAT3260.csv' using 2:1 I get a detailed plot with the values at their original precision. However, when I use gnuplot within Python (having read in the file to float lists x and y) using: g = Gnuplot.Gnuplot(debug=1) d = Gnuplot.Data(x, y, with_='points') g.plot(d) I get a plot with plotted values rounded or truncated to 7 digits of precision, it seems. Is there a way to preserve the precision of the data when using pygnuplot?  Richard Langley   Richard B. Langley Email: lang@...   Geodetic Research Laboratory Web: http://gge.unb.ca   Dept. of Geodesy and Geomatics Engineering Phone: +1 506 4535142   University of New Brunswick Fax: +1 506 4534943   Fredericton, N.B., Canada E3B 5A3   Fredericton? Where's that? See: http://www.fredericton.ca/   
From: Michael Haggerty <mhagger@al...>  20131209 07:47:18

On 12/08/2013 02:49 PM, Richard Langley wrote: > I have a file of x,y real data pairs with the values to 9 digits of > precision. When I use gnuplot to plot the data directly using, say: > plot 'HHAT3260.csv' using 2:1 > I get a detailed plot with the values at their original precision. > However, when I use gnuplot within Python (having read in the file to > float lists x and y) using: > g = Gnuplot.Gnuplot(debug=1) > d = Gnuplot.Data(x, y, with_='points') > g.plot(d) > I get a plot with plotted values rounded or truncated to 7 digits of > precision, it seems. Is there a way to preserve the precision of the > data when using pygnuplot? Gnuplot.py's default is to treat data as 32bit floating point numbers. But if you explicitly pass doubleprecision data to Gnuplot.Data(), then I think it will pass the data to gnuplot with the higher precision. I.e., do something like d = Gnuplot.Data( numpy.array(x, dtype=numpy.float64), numpy.array(y, dtype=numpy.float64), with_='points', ) Michael  Michael Haggerty mhagger@... http://softwareswirl.blogspot.com/ 
From: Richard B. Langley <lang@un...>  20131209 14:40:59

Thanks, Michael, but, sadly, that did not work.  Richard On Monday, December 9, 2013,343, at 3:47 AM, Michael Haggerty wrote: > On 12/08/2013 02:49 PM, Richard Langley wrote: >> I have a file of x,y real data pairs with the values to 9 digits of >> precision. When I use gnuplot to plot the data directly using, say: >> plot 'HHAT3260.csv' using 2:1 >> I get a detailed plot with the values at their original precision. >> However, when I use gnuplot within Python (having read in the file to >> float lists x and y) using: >> g = Gnuplot.Gnuplot(debug=1) >> d = Gnuplot.Data(x, y, with_='points') >> g.plot(d) >> I get a plot with plotted values rounded or truncated to 7 digits of >> precision, it seems. Is there a way to preserve the precision of the >> data when using pygnuplot? > > Gnuplot.py's default is to treat data as 32bit floating point numbers. > But if you explicitly pass doubleprecision data to Gnuplot.Data(), > then I think it will pass the data to gnuplot with the higher precision. > I.e., do something like > > d = Gnuplot.Data( > numpy.array(x, dtype=numpy.float64), > numpy.array(y, dtype=numpy.float64), > with_='points', > ) > > Michael > >  > Michael Haggerty > mhagger@... > http://softwareswirl.blogspot.com/   Richard B. Langley Email: lang@...   Geodetic Research Laboratory Web: http://gge.unb.ca/   Dept. of Geodesy and Geomatics Engineering Phone: +1 506 4535142   University of New Brunswick Fax: +1 506 4534943   Fredericton, N.B., Canada E3B 5A3   Fredericton? Where's that? See: http://www.fredericton.ca/   
From: Michael Haggerty <mhagger@al...>  20131209 15:09:44

On 12/09/2013 03:40 PM, Richard B. Langley wrote: > On Monday, December 9, 2013,343, at 3:47 AM, Michael Haggerty wrote: >> On 12/08/2013 02:49 PM, Richard Langley wrote: >>> I have a file of x,y real data pairs with the values to 9 digits of >>> precision. When I use gnuplot to plot the data directly using, say: >>> plot 'HHAT3260.csv' using 2:1 >>> I get a detailed plot with the values at their original precision. >>> However, when I use gnuplot within Python (having read in the file to >>> float lists x and y) using: >>> g = Gnuplot.Gnuplot(debug=1) >>> d = Gnuplot.Data(x, y, with_='points') >>> g.plot(d) >>> I get a plot with plotted values rounded or truncated to 7 digits of >>> precision, it seems. Is there a way to preserve the precision of the >>> data when using pygnuplot? >> >> Gnuplot.py's default is to treat data as 32bit floating point numbers. >> But if you explicitly pass doubleprecision data to Gnuplot.Data(), >> then I think it will pass the data to gnuplot with the higher precision. >> I.e., do something like >> >> d = Gnuplot.Data( >> numpy.array(x, dtype=numpy.float64), >> numpy.array(y, dtype=numpy.float64), >> with_='points', >> ) > Thanks, Michael, but, sadly, that did not work. >  Richard Hmm, sorry, I thought I had built something like that in. If so, it would have been more then 10 years ago, so I hope you will forgive me :) The formatting is done by the function write_array() in the file utils.py. The individual elements are formatted using '%s'. If you change that to '%r' (in two places) or '%.20g' or something like that, I think you'll get what you want. Or, of course, you can always write the data to a file yourself, similar to how PlotItems.Data() does it. Michael  Michael Haggerty mhagger@... http://softwareswirl.blogspot.com/ 
From: Richard Langley <lang@un...>  20131210 03:46:02

Michael: Neither of those suggestions seemed to work. However, in the float_array function in utils.py, simply changing "return numpy.asarray(m, numpy.float32)" to "return numpy.asarray(m, numpy.float64)" did the trick for me. I have another question, but I'll ask it in a separate email.  Richard   Richard B. Langley Email: lang@...   Geodetic Research Laboratory Web: http://gge.unb.ca   Dept. of Geodesy and Geomatics Engineering Phone: +1 506 4535142   University of New Brunswick Fax: +1 506 4534943   Fredericton, N.B., Canada E3B 5A3   Fredericton? Where's that? See: http://www.fredericton.ca/   ________________________________________ From: Michael Haggerty [mhagger@...] Sent: Monday, December 09, 2013 11:09 AM To: Richard Langley Cc: gnuplotpyusers@... Subject: Re: [Gnuplotpyusers] Resolution of Plots On 12/09/2013 03:40 PM, Richard B. Langley wrote: > On Monday, December 9, 2013,343, at 3:47 AM, Michael Haggerty wrote: >> On 12/08/2013 02:49 PM, Richard Langley wrote: >>> I have a file of x,y real data pairs with the values to 9 digits of >>> precision. When I use gnuplot to plot the data directly using, say: >>> plot 'HHAT3260.csv' using 2:1 >>> I get a detailed plot with the values at their original precision. >>> However, when I use gnuplot within Python (having read in the file to >>> float lists x and y) using: >>> g = Gnuplot.Gnuplot(debug=1) >>> d = Gnuplot.Data(x, y, with_='points') >>> g.plot(d) >>> I get a plot with plotted values rounded or truncated to 7 digits of >>> precision, it seems. Is there a way to preserve the precision of the >>> data when using pygnuplot? >> >> Gnuplot.py's default is to treat data as 32bit floating point numbers. >> But if you explicitly pass doubleprecision data to Gnuplot.Data(), >> then I think it will pass the data to gnuplot with the higher precision. >> I.e., do something like >> >> d = Gnuplot.Data( >> numpy.array(x, dtype=numpy.float64), >> numpy.array(y, dtype=numpy.float64), >> with_='points', >> ) > Thanks, Michael, but, sadly, that did not work. >  Richard Hmm, sorry, I thought I had built something like that in. If so, it would have been more then 10 years ago, so I hope you will forgive me :) The formatting is done by the function write_array() in the file utils.py. The individual elements are formatted using '%s'. If you change that to '%r' (in two places) or '%.20g' or something like that, I think you'll get what you want. Or, of course, you can always write the data to a file yourself, similar to how PlotItems.Data() does it. Michael  Michael Haggerty mhagger@... http://softwareswirl.blogspot.com/ 
Sign up for the SourceForge newsletter:
No, thanks