Pfaff, Bernhard
2003-Oct-21 11:04 UTC
[R] png() and/or jpeg(): line missing by using box(which="outer")
Dear R list, I do encounter the following problem by generating either a png-file (example below) or a jpeg-file: By employing 'box(which="outer")' a box is drawn, except for the right line. If I generate the plot without the 'box(which="outer")', a line at the bottom in the graphics file still appears. However, both plots are displayed correctly in the R Graphics Device Window, i.e with a box including the right side or one without any lines at the outer margins of the plot. Now, I want either a file - including the right side of box or one that has none on all sides. test <- rnorm(100) par(mar=c(6,4,6,4), oma=c(1,1,1,1)) png("test1.png") plot(test) grid() box(which="outer") box(which="plot") dev.off() png("test2.png") plot(test) grid() box(which="plot") dev.off() Incidentally, both functions are calling .Internal(devga(....)). I have not encountered this problem with version R 1.7.1 (for which I used the binary distribution on CRAN). Now, I have source compiled R 1.8.0. Although, everything passed 'make check', I am wondering if it could be possible that 'devga.c' or any other necessary file for running png() or jpeg() have not been compiled 'correctly', or do I have simply to adjust a par()-argument? Any pointers or help is appreciated. Bernhard platform: "i386-pc-mingw32" arch: "i386" os: "mingw32" system: "i386, mingw32" major: "1" minor: "8.0" Windows NT 5.0 -------------------------------------------------------------------------------- The information contained herein is confidential and is intended solely for the addressee. Access by any other party is unauthorised without the express written permission of the sender. If you are not the intended recipient, please contact the sender either via the company switchboard on +44 (0)20 7623 8000, or via e-mail return. If you have received this e-mail in error or wish to read our e-mail disclaimer statement and monitoring policy, please refer to http://www.drkw.com/disc/email/ or contact the sender.
Prof Brian D Ripley
2003-Oct-21 11:32 UTC
[R] png() and/or jpeg(): line missing by using box(which="outer")
It is probably a bug: does it happen when you copy from the screen in png? I would expect not, hence that may be a workaround for you. When I have both time and access to a Windows machine I may be able it take a closer look: meanwhile you do have access and have the source code so please investigate it yourself and submit a patch. On Tue, 21 Oct 2003, Pfaff, Bernhard wrote:> Dear R list, > > I do encounter the following problem by generating either a png-file > (example below) or a jpeg-file: > By employing 'box(which="outer")' a box is drawn, except for the right line. > If I generate the plot without the 'box(which="outer")', a line at the > bottom in the graphics file still appears. However, both plots are displayed > correctly in the R Graphics Device Window, i.e with a box including the > right side or one without any lines at the outer margins of the plot. Now, I > want either a file - including the right side of box or one that has none on > all sides. > > test <- rnorm(100) > par(mar=c(6,4,6,4), oma=c(1,1,1,1)) > png("test1.png") > plot(test) > grid() > box(which="outer") > box(which="plot") > dev.off() > > png("test2.png") > plot(test) > grid() > box(which="plot") > dev.off() > > Incidentally, both functions are calling .Internal(devga(....)). I have not > encountered this problem with version R 1.7.1 (for which I used the binary > distribution on CRAN). Now, I have source compiled R 1.8.0. Although, > everything passed 'make check', I am wondering if it could be possible that > 'devga.c' or any other necessary file for running png() or jpeg() have not > been compiled 'correctly', or do I have simply to adjust a par()-argument? > > Any pointers or help is appreciated. > > > Bernhard > > > platform: "i386-pc-mingw32" > arch: "i386" > os: "mingw32" > system: "i386, mingw32" > major: "1" > minor: "8.0" > Windows NT 5.0 > > > > -------------------------------------------------------------------------------- > The information contained herein is confidential and is intended solely for the > addressee. Access by any other party is unauthorised without the express > written permission of the sender. If you are not the intended recipient, please > contact the sender either via the company switchboard on +44 (0)20 7623 8000, or > via e-mail return. If you have received this e-mail in error or wish to read our > e-mail disclaimer statement and monitoring policy, please refer to > http://www.drkw.com/disc/email/ or contact the sender. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595
Prof Brian Ripley
2003-Nov-02 13:44 UTC
[R] png() and/or jpeg(): line missing by using box(which="outer")
I have an answer for the first of these. box("outer") tries to draw a polyline at (0,0), (0,1), (1,1), (1,0), (1,0) in device coordinates. Due to rounding error, 1 was being plotted at pixel 480, and there are only pixels 0...479. This *was* also happening on screen, but for the default screen size on my machine it was being rounded down and so shown correctly. I have added a `fuzz' to ensure 1 gets mapped to pixel 479. On Tue, 21 Oct 2003, Pfaff, Bernhard wrote:> Dear R list, > > I do encounter the following problem by generating either a png-file > (example below) or a jpeg-file: > By employing 'box(which="outer")' a box is drawn, except for the right line. > If I generate the plot without the 'box(which="outer")', a line at the > bottom in the graphics file still appears. However, both plots are displayed > correctly in the R Graphics Device Window, i.e with a box including the > right side or one without any lines at the outer margins of the plot. Now, I > want either a file - including the right side of box or one that has none on > all sides. > > test <- rnorm(100) > par(mar=c(6,4,6,4), oma=c(1,1,1,1)) > png("test1.png") > plot(test) > grid() > box(which="outer") > box(which="plot") > dev.off() > > png("test2.png") > plot(test) > grid() > box(which="plot") > dev.off() > > Incidentally, both functions are calling .Internal(devga(....)). I have not > encountered this problem with version R 1.7.1 (for which I used the binary > distribution on CRAN). Now, I have source compiled R 1.8.0. Although, > everything passed 'make check', I am wondering if it could be possible that > 'devga.c' or any other necessary file for running png() or jpeg() have not > been compiled 'correctly', or do I have simply to adjust a par()-argument? > > Any pointers or help is appreciated. > > > Bernhard > > > platform: "i386-pc-mingw32" > arch: "i386" > os: "mingw32" > system: "i386, mingw32" > major: "1" > minor: "8.0" > Windows NT 5.0 > > > > -------------------------------------------------------------------------------- > The information contained herein is confidential and is intended solely for the > addressee. Access by any other party is unauthorised without the express > written permission of the sender. If you are not the intended recipient, please > contact the sender either via the company switchboard on +44 (0)20 7623 8000, or > via e-mail return. If you have received this e-mail in error or wish to read our > e-mail disclaimer statement and monitoring policy, please refer to > http://www.drkw.com/disc/email/ or contact the sender. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595