Graph size, transparency and PDF, EPS, and PNG

547 views
Skip to first unread message

Muenchen, Robert A (Bob)

unread,
Jun 3, 2009, 5:52:35 PM6/3/09
to ggp...@googlegroups.com
Hi All,

This is a bit of a follow-up to the previous discussion about how to
plot large datasets. I was doing a scatterplot of 5,000 points with
transparency, saved as an encapsulated postscript file (EPS). The
postscript driver in R had not recorded transparency in the past so I
was double-checking it. Sure enough, the axes were there, but points
had vanished (a bit TOO transparent.)

So I switched to PDF, which gave me a 1 MB file in nice, high
resolution. But my publisher (Springer) prefers EPS. I happened to have
Adobe Acrobat Professional, so I used it to convert to EPS just to make
sure the lack of transparency is an EPS problem, not an R problem. To my
surprise, the transparency appeared and looked fine! So it seems that
the R postscript driver has a problem.

Unfortunately, the PDF to EPS conversion ballooned the file from 1 MB to
77 MB! Simply viewing it in LaTeX (Yap) took several minutes.

I then saved as a 600 dpi PNG file and it looks great at only 340KB! So
Hadley's advice on this is good. And I think R's postscript driver
(which creates EPS) has a bug, or perhaps they just did not view
transparency as important.

This applies to confidence bands around regression lines since they use
transparency. They don't get huge in EPS but the do disappear when using
R's postscritpt driver.

Cheers,
Bob

=========================================================
Bob Muenchen (pronounced Min'-chen),
Manager, Research Computing Support
U of TN Office of Information Technology
Stokely Management Center, Suite 200
916 Volunteer Blvd., Knoxville, TN 37996-0520
Voice: (865) 974-5230
FAX: (865) 974-4810
Email: muen...@utk.edu
Web: http://oit.utk.edu/research <http://oit.utk.edu/scc>
Map to Office: http://www.utk.edu/maps
Newsletter: http://listserv.utk.edu/archives/rcnews.html
<http://listserv.utk.edu/archives/statnews.html>
=========================================================


Karl Ove Hufthammer

unread,
Jun 4, 2009, 5:20:53 AM6/4/09
to Muenchen, Robert A (Bob), ggp...@googlegroups.com
Quoting "Muenchen, Robert A (Bob)" <muen...@utk.edu>:

> I then saved as a 600 dpi PNG file and it looks great at only 340KB! So
> Hadley's advice on this is good. And I think R's postscript driver
> (which creates EPS) has a bug, or perhaps they just did not view
> transparency as important.

This is not a bug. PostScript (PS/EPS) just does not support (alpha)
transparency.

--
Karl Ove Hufthammer

JiHO

unread,
Jun 4, 2009, 7:13:00 AM6/4/09
to Muenchen, Robert A (Bob), ggp...@googlegroups.com
On 2009-June-03 , at 23:52 , Muenchen, Robert A (Bob) wrote:

> To my
> surprise, the transparency appeared and looked fine! So it seems that
> the R postscript driver has a problem.

No EPS, as a format, does not support transparency. see the comparison
between PDF and postscript about that:
http://en.wikipedia.org/wiki/Portable_Document_Format#Transparency
So what acrobat likely does is to convert the transparent parts into a
bitmap.

> Unfortunately, the PDF to EPS conversion ballooned the file from 1
> MB to
> 77 MB! Simply viewing it in LaTeX (Yap) took several minutes.

Judging from the size, acrobat must be producing a uncompressed TIFF
of high density for the transparent parts. However, if you can zoom
enough you should see some pixels.

> I then saved as a 600 dpi PNG file and it looks great at only 340KB!
> So
> Hadley's advice on this is good.

Hadley's advice is always good! ;)
However... ask the publisher before hand. First, most page layout
software (from LaTeX to Quark or InDesign) support PDF. So the
requirement for EPS is probably something that carried over from old
versions of their workflow. If you argue based on the limitations of
EPS vs. PDF regarding transparency, they should listen (and if they
don't, then they should at least explain heir reasons. Maybe they
don't think transparency s a good idea in the first place because it
prints badly or something).
If you end up needing to go the raster route (PNG) they will probably
have some stupid requirements also (like TIFF). You can convert from
PNG to TIFF with no loss of quality but you should first ask for the
resolution. For professionally printed material, it is not uncommon
for the resolution of the printer to be 1200 dpi and that's usually
what they ask for for line art. In that case you need to produce PNGs
at the correct resolution first.

Good luck with that.

JiHO
---
http://jo.irisson.free.fr/

Muenchen, Robert A (Bob)

unread,
Jun 4, 2009, 7:41:41 AM6/4/09
to ggp...@googlegroups.com
It turns out that the PDF to EPS conversion that I did resulted a
low-res bitmap file stored as EPS! It looked great on the screen but
looked like 96-dpi (my screen resolution) or so when I printed it.
Transparency and EPS format seems a bit mysterious as several sources
say that transparency is supported (in various ways) in EPS (e.g.
http://en.wikipedia.org/wiki/Transparent_pixels).

Cheers,
Bob

Karl Ove Hufthammer

unread,
Jun 4, 2009, 7:54:19 AM6/4/09
to ggp...@googlegroups.com
Quoting "Muenchen, Robert A (Bob)" <muen...@utk.edu>:

> It turns out that the PDF to EPS conversion that I did resulted a
> low-res bitmap file stored as EPS! It looked great on the screen but
> looked like 96-dpi (my screen resolution) or so when I printed it.
> Transparency and EPS format seems a bit mysterious as several sources
> say that transparency is supported (in various ways) in EPS (e.g.
> http://en.wikipedia.org/wiki/Transparent_pixels).

As this page says, PostScript only supports clipping and fully
transparent or fully opaque colours, neither which is of much use when
you want *partial* transparency. For that, you need to use PDF (or
SVG, or a raster graphics format such as PNG).

Also note that when printing a PDF containing transparency to a
PostScript printer, Adobe Reader internally rasterises the PDF
(converts it into a bitmap) before sending it.

--
Karl Ove Hufthammer

baptiste auguie

unread,
Jun 4, 2009, 8:29:01 AM6/4/09
to ggp...@googlegroups.com
although it is technically possible to have vector transparency in eps,

http://www.tinaja.com/glib/pstrans2.pdf

eps is clearly being superseded by pdf,
http://www.prepressure.com/postscript/basics/history/4

It always annoys me to do the conversion pdf -> eps for silly
publishers who end up rasterising it anyway to add some artistic blur
or something.

There is hope though: with ggplot2's ability to keep / remove a
portion of a plot (opts(keep=)), one could imagine a neat scenario
where the text, axes, ticks are exported in vector form and placed on
top of a raster export of the heavy (possibly transparent) data points
/ image.

Best,

baptiste
--
_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag
______________________________
Reply all
Reply to author
Forward
0 new messages