On my current home system, I am getting undesirable output from graphical devices such as png() and pdf(). The graphical output is blurry. I haven't experienced the problem on other systems. As you will see from the attached text file (more information on this file below), the problem does not occur when type='Xlib' is forced. The blurriness is more severe with bitmap output (yes, I am viewing the bitmap files at 100%), but occurs with pdf output as well. Software details: Fedora 10, with at least the following packages: -- R, R-core, R-devel -- cairo, cairo-devel -- pixman, pixman-devel -- libpng, libpng-devel -- poppler Everything is "current" and updated via Fedora's repository. R was installed via Fedora's repository. I've attached some commands and output in a text file. This file includes: (1) hardware information (2) information about my R installation (3) code for simple R graphics, with comments re output, plus URLs for the corresponding graphical output Any advice would be really appreciated. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: R-graphics.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081216/4aeeb875/attachment.txt>
Problems with graphical devices, e.g., png(), pdf(): blurry graphical output
5 messages · Y-H Chen, Brian Ripley, Martyn Plummer
Your PDF problems indicate a broken viewer. How were you viewing PDF? You have also not told us how you view PNG, but you would expect anti-aliased output to be blurry when viewed at 100% (or more). You need to be careful not to have anti-aliasing turned on in the viewer as well as in the file producer. Note that R does give you lots of options to tune the output to your intended use of it, so you have no cause to complain if you use an inappropriate set. Do remember that you cannot say 'the graphical output is blurry': it is just a binary file. Far too often, useRs blame R for issues in the viewers they use.
On Tue, 16 Dec 2008, Y-H Chen wrote:
On my current home system, I am getting undesirable output from graphical devices such as png() and pdf(). The graphical output is blurry. I haven't experienced the problem on other systems. As you will see from the attached text file (more information on this file below), the problem does not occur when type='Xlib' is forced. The blurriness is more severe with bitmap output (yes, I am viewing the bitmap files at 100%), but occurs with pdf output as well. Software details: Fedora 10, with at least the following packages: -- R, R-core, R-devel -- cairo, cairo-devel -- pixman, pixman-devel -- libpng, libpng-devel -- poppler Everything is "current" and updated via Fedora's repository. R was installed via Fedora's repository. I've attached some commands and output in a text file. This file includes: (1) hardware information (2) information about my R installation (3) code for simple R graphics, with comments re output, plus URLs for the corresponding graphical output Any advice would be really appreciated.
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
On Wed, Dec 17, 2008 at 12:54 AM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
Your PDF problems indicate a broken viewer. How were you viewing PDF?
You are absolutely correct about the PDF files; I've since checked the PDF files in other viewers and have not been able to reproduce the problem. There was definitely something wrong with my default viewer. I am most certainly embarrassed. As for the PNG files: I've viewed the PNG files on two different systems, in various viewers. On a Fedora system in Eye of Gnome, Firefox, Epiphany, GIMP, and gThumb. And, on a Windows system in Paint, Firefox, Internet Explorer, and GIMP. I see blurriness in all of these viewers for all of the files I originally claimed difficultly with (as mentioned in my last message, I don't see blurriness in the images produced via type='Xlib'). I'll do more tests on other systems once I get the chance, but that's what I see at the moment. The files are linked to in the text file I provided, and you are all invited to check those out if you are interested.
The artefacts that you see are a normal result of using bitmap graphics devices. I have tried to explain these below: I have looked at your figures in Eye of Gnome, with anti-aliasing turned off (Menu Edit/Preferences; Tab "Image View"; option "Smooth images when zoomed"). I recommend that you do the same.
png('test.png',antialias='none') # type is 'cairo'
plot(1:10)
dev.off()
## result: no fuzziness at all but the box is missing
## the top and left border lines
## http://www.piccdrop.com/images/1229495388.png
Cairo works in real (double precision) coordinates. But the line must be converted to bitmap to be displayed. When this is done without anti-aliasing, it is quite possible for a thin horizontal or vertical line to pass in-between the points on a grid that are sampled to form the bitmap image, and hence disappear.
png('test.png') # type is 'cairo'
plot(1:10)
dev.off()
## result: box lines fuzzy at top and left, and appears
## darker and thicker where the axes are overplotted
## http://www.piccdrop.com/images/1229495327.png
With anti-aliasing, a horizontal or vertical line may appear as a 1 pixel wide black line, but is more likely to appear as a 2 pixel wide grey line. When two such grey lines are over-plotted, they will create a darker grey line. The overplotted line also appears thicker, but this is an optical illusion.
png('test.png',type='Xlib')
plot(1:10)
dev.off()
## result: no fuzziness at all and no lines missing
## http://www.piccdrop.com/images/1229495428.png
Xlib works in integer coordinates. When a line is plotted in Xlib, the start and end coordinates are cast to integer before plotting. Hence horizontal/vertical lines will always appear, with a width of 1 pixel and overplotting does not change the appearance of a line. Martyn
On Wed, 2008-12-17 at 01:36 -0800, Y-H Chen wrote:
On Wed, Dec 17, 2008 at 12:54 AM, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
Your PDF problems indicate a broken viewer. How were you viewing PDF?
You are absolutely correct about the PDF files; I've since checked the PDF files in other viewers and have not been able to reproduce the problem. There was definitely something wrong with my default viewer. I am most certainly embarrassed. As for the PNG files: I've viewed the PNG files on two different systems, in various viewers. On a Fedora system in Eye of Gnome, Firefox, Epiphany, GIMP, and gThumb. And, on a Windows system in Paint, Firefox, Internet Explorer, and GIMP. I see blurriness in all of these viewers for all of the files I originally claimed difficultly with (as mentioned in my last message, I don't see blurriness in the images produced via type='Xlib'). I'll do more tests on other systems once I get the chance, but that's what I see at the moment. The files are linked to in the text file I provided, and you are all invited to check those out if you are interested.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-----------------------------------------------------------------------
This message and its attachments are strictly confidenti...{{dropped:8}}
On Wed, Dec 17, 2008 at 3:06 AM, Martyn Plummer <plummer at iarc.fr> wrote:
The artefacts that you see are a normal result of using bitmap graphics devices. I have tried to explain these below:
Thanks very much for your explanations, MP; they were quite informative!! I recognize that others may feel differently, but to me, the "default" PNG being produced by my system -- e.g., http://www.piccdrop.com/images/1229495327.png -- is not ideal for presentation on the web. E.g., the image mentioned in the last sentence is blurry at 100% in every web browser and image viewer I've tried (even when I turn off aliasing in Eye of Gnome, as MP suggests). Given my feelings about the blurriness, my question is: how can I produce a non-blurry image via png()? I recognize that I can do so via png('plot.png',type='Xlib') but, I am wondering if there are solutions that don't involve Xlib. I guess my second question (if anybody has patience for it) is: what is the philosophy behind the current behavior? I was able to find some of that here: http://www.cairographics.org/FAQ/#sharp_lines ... but I am wondering if somebody could elaborate on this philosophy in relationship to R and statistical graphics, or point me to some links that do so. The link above does suggest that sharp single-pixel lines are possible via Cairo. So: are sharp single-pixel lines possible via Cairo in R, and if so how (this of course the question I've asked above)? And if not, why? (Just to be clear: I'm not saying the current implementation is necessarily "bad." At present, I'm just trying to understand more about why it is the way it is.)