[R] PDF too large, PNG bad quality

Lasse Kliemann lasse-list-r-help-2009 at mail.plastictree.net
Fri Oct 23 02:34:59 CEST 2009


* Message by -Greg Snow- from Thu 2009-10-22:
 
> If you want to go the pdf route, then you need to find some way 
> to reduce redundant information while still getting the main 
> points of the plot.  With so many point, I would suggest 
> looking at the hexbin package (bioconductor I think) as one 
> approach, it will not be an identical scatterplot, but will 
> convey the information (possibly better) with much smaller 
> graphics file sizes.  There are other tools like sunflower 
> plots or others, but hexbin has worked well for me.
 
I took a look at the 'hexbin' package, and it is really 
interesting. You were right that it also helps to better display 
the data. Finally, this forced me to learn using the 'grid' 
package :-) I think I will use a pretty high number of bins, so 
the plot looks similar to the scatter plots I am used to -- with 
the addition of colors giving different densities.

> If you want to go the png route, the problem usually comes from 
> scaling the plot after producing it.  So, the solution is to 
> create the plot at the exact size and at the exact resolution 
> that you want to use it at in your document so that no scaling 
> needs to be done.  Use the png function, but don't accept the 
> defaults, choose the size and resolution.  If you later decide 
> on a different size of graph, recreate the file, don't let 
> LaTeX rescale the first one.

This was my strategy so far. For instance, for a figure that is 
to span the whole text block from left to right:

two_third_a4 <- 8.3 * 2/3
png("new.png",
    width=two_third_a4,
    height=two_third_a4,
    units="in",
    res=300)
plot(...)

Earlier I wrote that the PNG looks good when displayed 
separately, but looks inferior when embedded in the LaTeX PDF 
document. However, I now believe that the dependence is more on 
the viewer application. It looks good displayed separately with 
'qiv', but not with 'feh'. The PDF document looks inferior when 
displayed with 'evince' or 'epdfview', but it looks okay when 
displayed with 'xpdf'. I presume now that this phenomenon it not 
directly R-related.

I thank you and everyone who responded so quickly.

Lasse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091023/3512b895/attachment-0002.bin>


More information about the R-help mailing list