Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-24 Thread Joerg van den Hoff
On Wed, May 23, 2007 at 10:13:22AM -0700, Waichler, Scott R wrote:
 
 
 Scott
 
 Scott Waichler, Senior Research Scientist
 Pacific Northwest National Laboratory
 MSIN K9-36
 P.O. Box 999
 Richland, WA   99352USA
 509-372-4423 (voice)
 509-372-6089 (fax)
 [EMAIL PROTECTED]
 http://hydrology.pnl.gov
 
 ---
  
 
  -Original Message-
  From: Joerg van den Hoff [mailto:[EMAIL PROTECTED] 
  Sent: Wednesday, May 23, 2007 9:25 AM
  To: Waichler, Scott R
  Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED]
  Subject: Re: [R] Reducing the size of pdf graphics files 
  produced with R
  
  On Wed, May 23, 2007 at 07:24:04AM -0700, Waichler, Scott R wrote:
as you are using MacOS X, you'll have ghostscript 
  installed anyway. 
so try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' 
_does_ include compression. a quick test showed at least 
  a reduction 
by about a factor of 2 relative to `pdf()'. probably one 
  can fiddle 
with the ghostscript settings (cf. e.g. `Ps2pdf.htm' in the 
ghostscipt
docs: you
can adjust the resolution for images in the pdf file) to improve 
this, so as a last resort you could indeed export the graphics as 
postscript and do the conversion to `pdf' by adjusting 
  the `ps2pdf'
switches. but even with the default settings the pdf produced via 
dev2bitmap/ghostscript is the better solution. apart from 
  file size 
I by and then ran into problems when converting `pdf()' output to 
postscript later on, for instance.
   
   Can you give an example of dev2bitmap usage?  I tried using it in 
  `dev2bitmap(file = rf.pdf, type = pdfwrite)' copies the 
  current device to the pdf-file `rf.pdf', i.e. you should have 
  plotted something on the screen prior to using this (the 
  manpage tells you so much...). no `dev.off' is necessary in this case.
  
  in order to plot directly into the pdffile, you can use 
  `bitmap' instead of `dev2bitmap', i.e.
  
  use either:
  
  plot(1:10)
  dev2bitmap(file = rf1.pdf, type = pdfwrite)
  
  or:
  
  bitmap(file = rf2.pdf, type = pdfwrite)
  plot(1:10)
  dev.off()
  
  both should produce the desired output file (at least after 
  including the correct `width' and `height' settings).
 
 I tried the second method, using width=8.5, height=11, but the margins
 in the output were bad, as if it assumed a4 paper or something.  I tried
 inserting paper=special and paper=letter in the bitmap call, but
 both caused errors.  Also, the plot was in grayscale instead of color.  
 
 Scott Waichler

if you look at the source code of `bitmap' you'll see that it essentially
constructs a `gs' command (the string `cmd') which is fed by the output of the
R `postscript' device via a pipe (the manpage of `bitmap' tells the same).
so I presume if you don't get colour or seem to have wrong page size this has
nothing to do with R, but you need to check your ghostscript installation.
only guessing, though. 

joerg

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-24 Thread Chabot Denis
Hi again,

Many of you have suggested other means than pdf device and/or  
conversion/compression of pdf outside of R.

I ran some tests on a small, a medium-size and a large figure. Here I  
summarize the results, which depend very much on the original  
graphics file. Please note that I wish to retain a vector-based  
graphic file.

You'll find at the end of this message the R program used to produce  
the graphics files.

Starting with a small size graphic file: in order, these were  
produced by

1) postscript device
2) pdf device
3) bitmap device (pdf output)
4) dev2bitmap, pdf output, from a quartz window
5) quartz device saved to pdf via command quarts.save
6) quartz device saved to pdf via save menu in R gui

-rw-r--r--   1 chabotd  chabotd243446 May 23 21:00 test_ps_from_R.ps
-rw-r--r--   1 chabotd  chabotd572513 May 23 21:00  
test_pdf_from_R.pdf
-rw-r--r--   1 chabotd  chabotd600106 May 24 09:21  
test_pdf_bitmapR.pdf
-rw-r--r--   1 chabotd  chabotd600050 May 24 09:22  
test_dev2bitmap.pdf
-rw-r--r--   1 chabotd  chabotd   1657446 May 23 21:00  
test_pdf_from_quartz.save.pdf
-rw-r--r--   1 chabotd  chabotd572634 May 23 21:01  
test_pdf_from_quartz.menu.pdf

These show how test_pdf_from_R.pdf can be shrunk outside of R
1) the command pdftk
2) opening the pdf in any Mac OS X pdf viewer and doing print to  
compressed pdf

-rw-r--r--   1 chabotd  chabotd 68742 May 24 09:25  
test_pdf_pdftk.pdf
-rw-r--r--   1 chabotd  chabotd100660 May 23 21:16  
test_pdf_print_to_comppdf.pdf

Finally, these show 3 conversions from postscript to pdf outside of R
1) command ps2pdf
2) command epstopdf
3) command pstopdf

-rw-r--r--   1 chabotd  chabotd566626 May 23 21:12  
test_ps_ps2pdf.pdf
-rw-r--r--   1 chabotd  chabotd566587 May 24 10:21  
test_ps_epstopdf.pdf
-rw-r--r--   1 chabotd  chabotd   1939788 May 24 10:20  
test_ps_pstopdf.pdf

For this first example, all pdf produced directly within R were of  
similar size, except one (quartz.save) that was 3x larger. Producing  
a postscript file and transforming it into pdf resulted in no  
significant saving. However pdf output from R can be shrunk (here to  
12% of original size) with pdftk. So far I found no adverse effect of  
this shrinking.

I did the same with a larger graphic, this example came from Dave  
Watson. Using the same blocks as above:

Produced with R:
-rw-r--r--   1 chabotd  chabotd854320 May 24 09:08  
mauna_ps_from_R.eps
-rw-r--r--   1 chabotd  chabotd   1000504 May 24 09:08  
mauna_pdf_from_R.pdf
-rw-r--r--   1 chabotd  chabotd 96737 May 24 09:08  
mauna_pdf_bitmapR.pdf
-rw-r--r--   1 chabotd  chabotd 97236 May 24 09:17  
mauna_dev2bitmap.pdf
-rw-r--r--   1 chabotd  chabotd468195 May 24 09:08  
mauna_pdf_from_quartz.save.pdf
-rw-r--r--   1 chabotd  chabotd999853 May 24 09:09  
mauna_pdf_from_quartz.menu.pdf

PS to pdf outside of R
-rw-r--r--   1 chabotd  chabotd 95024 May 24 09:11  
mauna_ps_ps2pdf.pdf
-rw-r--r--   1 chabotd  chabotd603021 May 24 10:40  
mauna_ps_pstopdf.pdf
-rw-r--r--   1 chabotd  chabotd 95015 May 24 10:40  
mauna_ps_epstopdf.pdf

pdf transformation outside of R
-rw-r--r--   1 chabotd  chabotd104487 May 24 09:12  
mauna_pdf_pdftk.pdf
-rw-r--r--   1 chabotd  chabotd134663 May 24 09:23  
mauna_print_to_comppdf.pdf

For this example, different methods of producing pdf within R had  
very different file sizes. The two methods based on quartz performed  
in reverse order compare to the previous example. Overall, using  
bitmap device or postscript-transformed-to-pdf outside of R produced  
files about 10% the size of the file produced by pdf device. But the  
latter could be shrunk almost as much using pdftk.

Finally, a larger-size example:
Produced with R:
-rw-r--r--   1 chabotd  chabotd   1426330 May 23 20:54 fig_ps_from_R.ps
-rw-r--r--   1 chabotd  chabotd   3384788 May 23 20:54  
fig_pdf_from_R.pdf
-rw-r--r--   1 chabotd  chabotd   3494689 May 24 09:03  
fig_pdf_bitmapR.pdf
-rw-r--r--   1 chabotd  chabotd   3494689 May 24 10:46  
fig_dev2bitmap.pdf
-rw-r--r--   1 chabotd  chabotd   3384832 May 23 20:54  
fig_pdf_from_quartz.menu.pdf
-rw-r--r--   1 chabotd  chabotd   9583552 May 23 20:52  
fig_pdf_from_quartz.save.pdf

PS to pdf outside of R
-rw-r--r--   1 chabotd  chabotd   3356223 May 23 21:12 fig_ps_ps2pdf.pdf
-rw-r--r--   1 chabotd  chabotd  11397461 May 23 23:51  
fig_ps_pstopdf.pdf
-rw-r--r--   1 chabotd  chabotd   3354762 May 23 23:55  
fig_ps_epstopdf.pdf

pdf transformation outside of R
-rw-r--r--   1 chabotd  chabotd379307 May 23 22:31  
fig_pdf_comptk.pdf
-rw-r--r--   1 chabotd  chabotd520509 May 24 00:19  
fig_pdf_print_to_comppdf.pdf

This time, as in the first example, there was little benefit going  
the bitmap device or ps to pdf route. Only shrinking the pdf with  
pdftk was effective. So examples with a lot of objects on the plot do  
not seem to benefit from postscript use, but one example with few  
objects (but objects that 

Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-23 Thread Waichler, Scott R
 as you are using MacOS X, you'll have ghostscript installed anyway. so
 try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' _does_
 include compression. a quick test showed at least a reduction by about
 a factor of 2 relative to `pdf()'. probably one can fiddle with the
 ghostscript settings (cf. e.g. `Ps2pdf.htm' in the ghostscipt 
 docs: you
 can adjust the resolution for images in the pdf file) to
 improve this, so as a last resort you could indeed export the graphics
 as postscript and do the conversion to `pdf' by adjusting the `ps2pdf'
 switches. but even with the default settings the pdf produced via
 dev2bitmap/ghostscript is the better solution. apart from file size I
 by and then ran into problems when converting `pdf()' output to
 postscript later on, for instance.

Can you give an example of dev2bitmap usage?  I tried using it in place
of a pdf() statement.  An X11 window opened and my figure flew by, but I
didn't get the file output.  I also used dev2bitmap after opening a
pdf() and just before the dev.off() statement, since the help says it
works on the current device, but again no written output.  What am I
doing wrong?

I tried:
  dev2bitmap(file = plotfile2, type=pdfwrite, width=8.5, height=11,
pointsize=12)
  print(myplot())
  dev.off()

and

  pdf(file = plotfile, paper=letter, width=8.5, height=11,
pointsize=12)
  print(myplot())
  dev2bitmap(file = plotfile2, type=pdfwrite, width=8.5, height=11,
pointsize=12)
  dev.off()

Thanks,
Scott Waichler
scott.waichler _at_ pnl.gov

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-23 Thread Joerg van den Hoff
On Wed, May 23, 2007 at 07:24:04AM -0700, Waichler, Scott R wrote:
  as you are using MacOS X, you'll have ghostscript installed anyway. so
  try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' _does_
  include compression. a quick test showed at least a reduction by about
  a factor of 2 relative to `pdf()'. probably one can fiddle with the
  ghostscript settings (cf. e.g. `Ps2pdf.htm' in the ghostscipt 
  docs: you
  can adjust the resolution for images in the pdf file) to
  improve this, so as a last resort you could indeed export the graphics
  as postscript and do the conversion to `pdf' by adjusting the `ps2pdf'
  switches. but even with the default settings the pdf produced via
  dev2bitmap/ghostscript is the better solution. apart from file size I
  by and then ran into problems when converting `pdf()' output to
  postscript later on, for instance.
 
 Can you give an example of dev2bitmap usage?  I tried using it in place
 of a pdf() statement.  An X11 window opened and my figure flew by, but I
 didn't get the file output.  I also used dev2bitmap after opening a
 pdf() and just before the dev.off() statement, since the help says it
 works on the current device, but again no written output.  What am I
 doing wrong?
 
 I tried:
   dev2bitmap(file = plotfile2, type=pdfwrite, width=8.5, height=11,
 pointsize=12)
   print(myplot())
   dev.off()
 
 and
 
   pdf(file = plotfile, paper=letter, width=8.5, height=11,
 pointsize=12)
   print(myplot())
   dev2bitmap(file = plotfile2, type=pdfwrite, width=8.5, height=11,
 pointsize=12)
   dev.off()
 
 Thanks,
 Scott Waichler
 scott.waichler _at_ pnl.gov

`dev2bitmap(file = rf.pdf, type = pdfwrite)' copies the current device to 
the
pdf-file `rf.pdf', i.e. you should have plotted something on the screen prior to
using this (the manpage tells you so much...). no `dev.off' is necessary in 
this case.

in order to plot directly into the pdffile, you can use `bitmap' instead of
`dev2bitmap', i.e.

use either:

plot(1:10)
dev2bitmap(file = rf1.pdf, type = pdfwrite)

or:

bitmap(file = rf2.pdf, type = pdfwrite)
plot(1:10)
dev.off()


both should produce the desired output file (at least after including 
the correct `width' and `height' settings).


joerg

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-23 Thread Waichler, Scott R


Scott

Scott Waichler, Senior Research Scientist
Pacific Northwest National Laboratory
MSIN K9-36
P.O. Box 999
Richland, WA   99352USA
509-372-4423 (voice)
509-372-6089 (fax)
[EMAIL PROTECTED]
http://hydrology.pnl.gov

---
 

 -Original Message-
 From: Joerg van den Hoff [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 23, 2007 9:25 AM
 To: Waichler, Scott R
 Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED]
 Subject: Re: [R] Reducing the size of pdf graphics files 
 produced with R
 
 On Wed, May 23, 2007 at 07:24:04AM -0700, Waichler, Scott R wrote:
   as you are using MacOS X, you'll have ghostscript 
 installed anyway. 
   so try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' 
   _does_ include compression. a quick test showed at least 
 a reduction 
   by about a factor of 2 relative to `pdf()'. probably one 
 can fiddle 
   with the ghostscript settings (cf. e.g. `Ps2pdf.htm' in the 
   ghostscipt
   docs: you
   can adjust the resolution for images in the pdf file) to improve 
   this, so as a last resort you could indeed export the graphics as 
   postscript and do the conversion to `pdf' by adjusting 
 the `ps2pdf'
   switches. but even with the default settings the pdf produced via 
   dev2bitmap/ghostscript is the better solution. apart from 
 file size 
   I by and then ran into problems when converting `pdf()' output to 
   postscript later on, for instance.
  
  Can you give an example of dev2bitmap usage?  I tried using it in 
 `dev2bitmap(file = rf.pdf, type = pdfwrite)' copies the 
 current device to the pdf-file `rf.pdf', i.e. you should have 
 plotted something on the screen prior to using this (the 
 manpage tells you so much...). no `dev.off' is necessary in this case.
 
 in order to plot directly into the pdffile, you can use 
 `bitmap' instead of `dev2bitmap', i.e.
 
 use either:
 
 plot(1:10)
 dev2bitmap(file = rf1.pdf, type = pdfwrite)
 
 or:
 
 bitmap(file = rf2.pdf, type = pdfwrite)
 plot(1:10)
 dev.off()
 
 both should produce the desired output file (at least after 
 including the correct `width' and `height' settings).

I tried the second method, using width=8.5, height=11, but the margins
in the output were bad, as if it assumed a4 paper or something.  I tried
inserting paper=special and paper=letter in the bitmap call, but
both caused errors.  Also, the plot was in grayscale instead of color.  

Scott Waichler

__
R-help@stat.math.ethz.ch 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.


[R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Chabot Denis
Hi,

Without trying to print 100 points (see http:// 
finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often print  
maps for which I do not want to loose too much of coastline detail,  
and/or plots with 1000-5000 points (yes, some are on top of each  
other, but using transparency (i.e. rgb colors with alpha  
information) this actually comes through as useful information.

But the files are large (not as large as in the thread above of  
course, 800 KB to about 2 MB), especially when included in a LaTeX  
document by the dozen.

Acrobat (not the reader, the full program) has an option reduce file  
size. I don't know what it does, but it shrinks most of my plots to  
about 30% or original size, and I cannot detect any loss of detail  
even when zooming several times. But it is a pain to do this with  
Acrobat when you generate many plots... And you need to buy Acrobat.

Is this something the pdf device could do in a future version? I  
tried the million points example from the thread above and the 55  
MB file was reduced to 6.9 MB, an even better shrinking I see on my  
usual plots.


Denis Chabot

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Prof Brian Ripley
From the help page

  'pdf' writes uncompressed PDF.  It is primarily intended for
  producing PDF graphics for inclusion in other documents, and
  PDF-includers such as 'pdftex' are usually able to handle
  compression.

If you are able to contribute a stream compressor, R will produce smaller 
plots.  Otherwise it is unlikely to happen (and it any case would be a
smaller contribution than that of the author of pdf(), who is quite happy 
with external compressors).

Acrobat does other things (not all of which it tells you about), but 
compression is the main advantage.

On Tue, 22 May 2007, Chabot Denis wrote:

 Hi,

 Without trying to print 100 points (see http://
 finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often print
 maps for which I do not want to loose too much of coastline detail,
 and/or plots with 1000-5000 points (yes, some are on top of each
 other, but using transparency (i.e. rgb colors with alpha
 information) this actually comes through as useful information.

 But the files are large (not as large as in the thread above of
 course, 800 KB to about 2 MB), especially when included in a LaTeX
 document by the dozen.

 Acrobat (not the reader, the full program) has an option reduce file
 size. I don't know what it does, but it shrinks most of my plots to
 about 30% or original size, and I cannot detect any loss of detail
 even when zooming several times. But it is a pain to do this with
 Acrobat when you generate many plots... And you need to buy Acrobat.

 Is this something the pdf device could do in a future version? I
 tried the million points example from the thread above and the 55
 MB file was reduced to 6.9 MB, an even better shrinking I see on my
 usual plots.


 Denis Chabot

 __
 R-help@stat.math.ethz.ch 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.


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Sundar Dorai-Raj
You need not buy Acrobat. There are two free software programs that will 
compress pdf files:

http://www.cutepdf.com
http://www.cs.wisc.edu/~ghost/ (and in particular GSView)

They both allow several levels of compression.

Thanks,

--sundar

Chabot Denis said the following on 5/22/2007 3:32 AM:
 Hi,
 
 Without trying to print 100 points (see http:// 
 finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often print  
 maps for which I do not want to loose too much of coastline detail,  
 and/or plots with 1000-5000 points (yes, some are on top of each  
 other, but using transparency (i.e. rgb colors with alpha  
 information) this actually comes through as useful information.
 
 But the files are large (not as large as in the thread above of  
 course, 800 KB to about 2 MB), especially when included in a LaTeX  
 document by the dozen.
 
 Acrobat (not the reader, the full program) has an option reduce file  
 size. I don't know what it does, but it shrinks most of my plots to  
 about 30% or original size, and I cannot detect any loss of detail  
 even when zooming several times. But it is a pain to do this with  
 Acrobat when you generate many plots... And you need to buy Acrobat.
 
 Is this something the pdf device could do in a future version? I  
 tried the million points example from the thread above and the 55  
 MB file was reduced to 6.9 MB, an even better shrinking I see on my  
 usual plots.
 
 
 Denis Chabot
 
 __
 R-help@stat.math.ethz.ch 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.

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Chabot Denis
Thank you Prof. Ripley.

Believe me, I do not have the skills to contribute such a thing as a  
stream compressor and I DO appreciate the work and usefulness of the  
pdf device as it is. I do most of my plots with pdf device, the rest  
with quartz (especially when I'm not sure I'll want to save a plot)  
and (rarely) png when the pdf output is too large or for  
compatibility with microsoft applications.

I find the statement you took from the help page promising: I often  
include these large plots into LaTeX, so I'll investigate what form  
of compression pdftex can do.

Sincerely,

Denis
Le 07-05-22 à 12:47, Prof Brian Ripley a écrit :

 From the help page

  'pdf' writes uncompressed PDF.  It is primarily intended for
  producing PDF graphics for inclusion in other documents, and
  PDF-includers such as 'pdftex' are usually able to handle
  compression.

 If you are able to contribute a stream compressor, R will produce  
 smaller plots.  Otherwise it is unlikely to happen (and it any case  
 would be a
 smaller contribution than that of the author of pdf(), who is quite  
 happy with external compressors).

 Acrobat does other things (not all of which it tells you about),  
 but compression is the main advantage.

 On Tue, 22 May 2007, Chabot Denis wrote:

 Hi,

 Without trying to print 100 points (see http://
 finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often print
 maps for which I do not want to loose too much of coastline detail,
 and/or plots with 1000-5000 points (yes, some are on top of each
 other, but using transparency (i.e. rgb colors with alpha
 information) this actually comes through as useful information.

 But the files are large (not as large as in the thread above of
 course, 800 KB to about 2 MB), especially when included in a LaTeX
 document by the dozen.

 Acrobat (not the reader, the full program) has an option reduce file
 size. I don't know what it does, but it shrinks most of my plots to
 about 30% or original size, and I cannot detect any loss of detail
 even when zooming several times. But it is a pain to do this with
 Acrobat when you generate many plots... And you need to buy Acrobat.

 Is this something the pdf device could do in a future version? I
 tried the million points example from the thread above and the 55
 MB file was reduced to 6.9 MB, an even better shrinking I see on my
 usual plots.


 Denis Chabot

 __
 R-help@stat.math.ethz.ch 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.


 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 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, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Chabot Denis
Thank you Sundar,

Do plots being so reduced remain object based (i.e. not bitmaps)?

Denis
Le 07-05-22 à 13:19, Sundar Dorai-Raj a écrit :

 You need not buy Acrobat. There are two free software programs that  
 will compress pdf files:

 http://www.cutepdf.com
 http://www.cs.wisc.edu/~ghost/ (and in particular GSView)

 They both allow several levels of compression.

 Thanks,

 --sundar

 Chabot Denis said the following on 5/22/2007 3:32 AM:
 Hi,
 Without trying to print 100 points (see http://  
 finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often  
 print  maps for which I do not want to loose too much of coastline  
 detail,  and/or plots with 1000-5000 points (yes, some are on top  
 of each  other, but using transparency (i.e. rgb colors with  
 alpha  information) this actually comes through as useful  
 information.
 But the files are large (not as large as in the thread above of   
 course, 800 KB to about 2 MB), especially when included in a  
 LaTeX  document by the dozen.
 Acrobat (not the reader, the full program) has an option reduce  
 file  size. I don't know what it does, but it shrinks most of my  
 plots to  about 30% or original size, and I cannot detect any loss  
 of detail  even when zooming several times. But it is a pain to do  
 this with  Acrobat when you generate many plots... And you need to  
 buy Acrobat.
 Is this something the pdf device could do in a future version? I   
 tried the million points example from the thread above and the  
 55  MB file was reduced to 6.9 MB, an even better shrinking I see  
 on my  usual plots.
 Denis Chabot
 __
 R-help@stat.math.ethz.ch 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.

__
R-help@stat.math.ethz.ch 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.


Re: [R] Reducing the size of pdf graphics files produced with R

2007-05-22 Thread Joerg van den Hoff
On Tue, May 22, 2007 at 01:06:06PM -0400, Chabot Denis wrote:
 Thank you Prof. Ripley.
 
 Believe me, I do not have the skills to contribute such a thing as a  
 stream compressor and I DO appreciate the work and usefulness of the  
 pdf device as it is. I do most of my plots with pdf device, the rest  
 with quartz (especially when I'm not sure I'll want to save a plot)  
 and (rarely) png when the pdf output is too large or for  
 compatibility with microsoft applications.
 
 I find the statement you took from the help page promising: I often  
 include these large plots into LaTeX, so I'll investigate what form  
 of compression pdftex can do.
 
 Sincerely,
 
 Denis
 Le 07-05-22 à 12:47, Prof Brian Ripley a écrit :
 
  From the help page
 
   'pdf' writes uncompressed PDF.  It is primarily intended for
   producing PDF graphics for inclusion in other documents, and
   PDF-includers such as 'pdftex' are usually able to handle
   compression.
 
  If you are able to contribute a stream compressor, R will produce  
  smaller plots.  Otherwise it is unlikely to happen (and it any case  
  would be a
  smaller contribution than that of the author of pdf(), who is quite  
  happy with external compressors).
 
  Acrobat does other things (not all of which it tells you about),  
  but compression is the main advantage.
 
  On Tue, 22 May 2007, Chabot Denis wrote:
 
  Hi,
 
  Without trying to print 100 points (see http://
  finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html), I often print
  maps for which I do not want to loose too much of coastline detail,
  and/or plots with 1000-5000 points (yes, some are on top of each
  other, but using transparency (i.e. rgb colors with alpha
  information) this actually comes through as useful information.
 
  But the files are large (not as large as in the thread above of
  course, 800 KB to about 2 MB), especially when included in a LaTeX
  document by the dozen.
 
  Acrobat (not the reader, the full program) has an option reduce file
  size. I don't know what it does, but it shrinks most of my plots to
  about 30% or original size, and I cannot detect any loss of detail
  even when zooming several times. But it is a pain to do this with
  Acrobat when you generate many plots... And you need to buy Acrobat.
 
  Is this something the pdf device could do in a future version? I
  tried the million points example from the thread above and the 55
  MB file was reduced to 6.9 MB, an even better shrinking I see on my
  usual plots.
 
 
  Denis Chabot
 
  __
  R-help@stat.math.ethz.ch 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.
 
 
  -- 
  Brian D. Ripley,  [EMAIL PROTECTED]
  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, UKFax:  +44 1865 272595
 
 __
 R-help@stat.math.ethz.ch 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.



as an attempt to suggest something more helpful than do write the
compressor yourself if you have a problem with pdf():

as you are using MacOS X, you'll have ghostscript installed anyway. so
try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' _does_
include compression. a quick test showed at least a reduction by about
a factor of 2 relative to `pdf()'. probably one can fiddle with the
ghostscript settings (cf. e.g. `Ps2pdf.htm' in the ghostscipt docs: you
can adjust the resolution for images in the pdf file) to
improve this, so as a last resort you could indeed export the graphics
as postscript and do the conversion to `pdf' by adjusting the `ps2pdf'
switches. but even with the default settings the pdf produced via
dev2bitmap/ghostscript is the better solution. apart from file size I
by and then ran into problems when converting `pdf()' output to
postscript later on, for instance.

hth,
joerg

__
R-help@stat.math.ethz.ch 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.