Stephen.Harker@spme.monash.edu.au
2003-Nov-24 04:20 UTC
[Rd] R postscript generation error (lines versus points) (PR#5285)
Full_Name: Stephen Harker Version: 1.80 OS: linux (Yellow Dog 3.0 on ppc) Submission from: (NULL) (130.194.13.101) In creating a postscript file from a set of data in which the points are plotted using `points()' and lines drawn using `lines()' I have found since upgrading from R version 1.4? to 1.8 that the two sets do not coinicide completely. This is best illustrated by a simple example given below. Here the X11() output appears correctly. However, the postscript output shows that the lines and points no longer coincide on the right hand side, whereas the left hand side is perfect. Output to other devices such as pdf is perfect. Possibly this reflects a different scaling being applied when points() or lines() are selected. One reason I found this is that I use a number of scripts in R to plot and multiplot data sets from x-ray and neutron powder diffraction analysis (and Rietveld fitting of this data in particularl). In these points() is used to plot the data and lines() to plot the refinement from the analysis. After upgrading I found these were misaligned. The example was created to mimic the problem. %%% Example follows: dtwoth <- seq(from=20,to=80,len=1024) dcount <- rnorm(dtwoth) # postscript(file="R-test2.ps",horizontal=FALSE, pointsize=18, onefile=FALSE, family="Helvetica", paper="a4") plot(dtwoth,dcount, xlim=c(min(dtwoth),max(dtwoth)),ylim=c(min(dcount),max(dcount)), yaxt="n",xaxs="i",yaxs="i",xlab="2theta",ylab="counts", type="n") lines(dtwoth,dcount) points(dtwoth,dcount) X11() plot(dtwoth,dcount, xlim=c(min(dtwoth),max(dtwoth)),ylim=c(min(dcount),max(dcount)), yaxt="n",xaxs="i",yaxs="i",xlab="2theta",ylab="counts", type="n") lines(dtwoth,dcount) points(dtwoth,dcount)
Peter Dalgaard
2003-Nov-24 10:13 UTC
[Rd] R postscript generation error (lines versus points) (PR#5285)
Stephen.Harker@spme.monash.edu.au writes:> Full_Name: Stephen Harker > Version: 1.80 > OS: linux (Yellow Dog 3.0 on ppc) > Submission from: (NULL) (130.194.13.101) > > > In creating a postscript file from a set of data in which the points are > plotted > using `points()' and lines drawn using `lines()' I have found since upgrading > from R version 1.4? to 1.8 that the two sets do not coinicide completely. This > is best illustrated by a simple example given below. Here the X11() output > appears correctly. However, the postscript output shows that the lines and > points no > longer coincide on the right hand side, whereas the left hand side is perfect. > Output to other devices such as pdf is perfect. Possibly this reflects a > different scaling being applied when points() or lines() are selected. > > One reason I found this is that I use a number of scripts in R to plot and > multiplot data sets from x-ray and neutron powder diffraction analysis (and > Rietveld fitting of this data in particularl). In these points() is used to > plot the data and lines() to plot the refinement from the analysis. After > upgrading I found these were > misaligned. The example was created to mimic the problem. > > %%% Example follows: > dtwoth <- seq(from=20,to=80,len=1024) > dcount <- rnorm(dtwoth) # > > postscript(file="R-test2.ps",horizontal=FALSE, > pointsize=18, onefile=FALSE, > family="Helvetica", paper="a4") > > plot(dtwoth,dcount, > xlim=c(min(dtwoth),max(dtwoth)),ylim=c(min(dcount),max(dcount)), > yaxt="n",xaxs="i",yaxs="i",xlab="2theta",ylab="counts", > type="n") > > lines(dtwoth,dcount) > points(dtwoth,dcount)[At the current rate, "1.80" would be about 36 years into the future. Latest version is 1.8.1.] I can't reproduce this with 1.8.0 on RedHat 8.0. Are you sure it isn't your Postscript viewer that is playing tricks on you?? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
p.murrell@auckland.ac.nz
2003-Nov-24 21:16 UTC
[Rd] R postscript generation error (lines versus points) (PR#5285)
Hi Peter Dalgaard wrote: > Stephen.Harker@spme.monash.edu.au writes: > > >>Full_Name: Stephen Harker >>Version: 1.80 >>OS: linux (Yellow Dog 3.0 on ppc) >>Submission from: (NULL) (130.194.13.101) >> >> >>In creating a postscript file from a set of data in which the points are >>plotted >>using `points()' and lines drawn using `lines()' I have found since upgrading >>from R version 1.4? to 1.8 that the two sets do not coinicide completely. This >>is best illustrated by a simple example given below. Here the X11() output >>appears correctly. However, the postscript output shows that the lines and >>points no >>longer coincide on the right hand side, whereas the left hand side is perfect. >>Output to other devices such as pdf is perfect. Possibly this reflects a >>different scaling being applied when points() or lines() are selected. >> >>One reason I found this is that I use a number of scripts in R to plot and >>multiplot data sets from x-ray and neutron powder diffraction analysis (and >>Rietveld fitting of this data in particularl). In these points() is used to >>plot the data and lines() to plot the refinement from the analysis. After >>upgrading I found these were >>misaligned. The example was created to mimic the problem. >> >>%%% Example follows: >>dtwoth <- seq(from=20,to=80,len=1024) >>dcount <- rnorm(dtwoth) # >> >>postscript(file="R-test2.ps",horizontal=FALSE, >> pointsize=18, onefile=FALSE, >> family="Helvetica", paper="a4") >> >>plot(dtwoth,dcount, >> xlim=c(min(dtwoth),max(dtwoth)),ylim=c(min(dcount),max(dcount)), >> yaxt="n",xaxs="i",yaxs="i",xlab="2theta",ylab="counts", >> type="n") >> >>lines(dtwoth,dcount) >>points(dtwoth,dcount) > > > [At the current rate, "1.80" would be about 36 years into the future. > Latest version is 1.8.1.] > > I can't reproduce this with 1.8.0 on RedHat 8.0. Are you sure it isn't > your Postscript viewer that is playing tricks on you?? I can't reproduce this either, but in trying your script I wonder if you are not properly "finishing" the postscript plot by calling dev.off before viewing. If I run your script, then view R-test2.ps without quitting R, the last few points at the right end of the plot are missing (because the postscript file is not yet complete). If I then quit R (the postscript file is completed and closed), the postscript output looks just like the X11 version. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Stephen.Harker@spme.monash.edu.au
2003-Nov-25 00:29 UTC
[Rd] R postscript generation error (lines versus points) (PR#5285)
Hi, On Tue, Nov 25, 2003 at 09:17:09AM +1300, Paul Murrell wrote:> Peter Dalgaard wrote: > > Stephen.Harker@spme.monash.edu.au writes: > >>Full_Name: Stephen Harker > >>Version: 1.80 > >>OS: linux (Yellow Dog 3.0 on ppc) > >>Submission from: (NULL) (130.194.13.101) > >> > >> > >>In creating a postscript file from a set of data in which the points are > >>plotted > >>using `points()' and lines drawn using `lines()' I have found since > upgrading > >>from R version 1.4? to 1.8 that the two sets do not coinicide > completely. [...] > > [At the current rate, "1.80" would be about 36 years into the future. > > Latest version is 1.8.1.]:-)> > I can't reproduce this with 1.8.0 on RedHat 8.0. Are you sure it isn't > > your Postscript viewer that is playing tricks on you??Yes and no: I get the same result in prints from a PostScript file or from files included into a LaTeX document in the case of the original scripts that caused me to try to create a test case. However, this morning having read this comment I tried this test script and I find it generates obvious `errors' using gs 8.11 (in /usr/local/bin) and none obvious using the system gs (7.05 in /usr/bin). I tried printing the file to a HP Laserjet 4MV, 8000N and a Konica 7155 and find it is similar to the gs 7.05 output. This suggests two problems: a problem with gs 8.11 as built on my system and that my test script does not duplicate the problem I thought I was illustrating. In the production scripts I have been using (with a history that goes back to the mid 90's) this occurs in a vary obvious mismatch in the lines() and points() that gets worse as x increases. I had thought that the script submitted duplicated the problem. Now it appears that it does not. For the scripts I was using I get the mismatch on printed postscript and similar(? I did not compare them fully) results with the screen.> I can't reproduce this either, but in trying your script I wonder if you > are not properly "finishing" the postscript plot by calling dev.off > before viewing. If I run your script, then view R-test2.ps without > quitting R, the last few points at the right end of the plot are missing > (because the postscript file is not yet complete). If I then quit R > (the postscript file is completed and closed), the postscript output > looks just like the X11 version.No: in my production versions dev.off() is called. I noticed the missing points you mentioned in the postscript file created. However, I did not worry about it as the error was noticeable in the alignment of the `peaks' and `points' prior to the missing points. I will need to test this further and to find a better way of duplicating the error (if error it is). I will have to try building R 1.8 on another system and test my Rietveld and other x-ray data plotting scripts to see if it matches my current problem. I will contact you when I have more data (useful or otherwise). -- Stephen Harker Stephen.Harker@spme.monash.edu.au School of Physics & Materials Engineering Monash University http://www.ph.adfa.edu.au/s-harker/ Baloney Baffles brains: Eric Frank Russell
Stephen.Harker@spme.monash.edu.au
2003-Dec-01 00:28 UTC
[Rd] R postscript generation error (lines versus points) (PR#5285)
For what worth it may be to the R development team: The main comment I have had, so far, on the submission of a bug report to the ghostscript list was as given below. I submitted a report plus a test file derived from the R file as submitted to the R-bugs list. The following comments appear to confirm a ghostscript bug. [Bug 687173] line misalignment with respect to points in 8.11 but not 8.00 http://bugs.ghostscript.com/show_bug.cgi?id=687173 ------- Additional Comments From alexcher@coscript.com 2003-11-28 04:38 ------- Ghostscript uses fixed point repressntation of the device coordinates. So there is a trade-off between the range and precission. File gxfixed.h was changed on 2003/02/15 22:37:01 to have 8 bit precission. The previous 12 bits was too large to accomodate large format inkjet printers at modern resolutions of 720 and 1200 dpi. The long chain of rlineto operations in the source file accumulates roniding errors, which becomes visible at the end of the line. There are several ways to improve the precission. (1) Use to 64-bit fixed numbers. This is very easy to do but may affect the performance. (2) Keep current point calculations in float point. Most precission problems are caused by inprecise current point calculations. (3) Replace all fixed arithmetic with floating pont one. This can improve the performance on some platforms. One can also work around the problem by: (1) compiling a private version of GS with higher precission and lower range. (2) fixing the PS file using UNIX text tools. -- Stephen Harker Stephen.Harker@spme.monash.edu.au School of Physics & Materials Engineering Monash University http://www.ph.adfa.edu.au/s-harker/ Baloney Baffles brains: Eric Frank Russell