[R] R versions and PostScript files

(Ted Harding) ted.harding at wlandres.net
Thu Jul 21 17:26:35 CEST 2011


On 21-Jul-11 13:24:32, Duncan Murdoch wrote:
> On 11-07-21 3:23 AM, pilchat wrote:
>> Dear R users,
>>
>> I have a desktop computer and a laptop, both of them
>> with Ubuntu Lucid. The former has R2.10 installed from
>> Ubuntu repositories (this is the most recent version
>> in the repositories), while the latter has R2.13 from
>> the CRAN repositories.
>>
>> I noticed that postscript files generated with R2.10
>> are "better" than files generated with the latest release
>> of R, in particular for plots with colored areas, such
>> as the output of image or persp. The thing is that my ps
>> viewer (e.g. gv or evince) is very slow in opening ps
>> files from R2.13, while it smoothly displays ps files
>> from R2.10, regardless of "encapsulation".
>>
>> I think this is related to differences in the way the
>> ps file is generated by the two versions of R, but I
>> don't know how to go deeper in the matter.
> 
> Postscript files are mostly text, so you can compare the
> two files and > see what the differences are. The NEWS
> file shows a number of changes since 2.10.0, but I can't
> see any that would cause problems for viewers.
> 
> Duncan Murdoch
> 
>> Is there anyone experiencing the same issue? Is there
>> any solution?
>>
>> Thank you in advance
>>
>> Cheers
>> Gaetano

Gaetano has now sent me two files, generated (as he posted
just now on R-help) by the same commands:

  setEPS()
  postscript (file="volc.eps",width=5,height=4)
  image(volcano)
  dev.off()

on his two machines:

volc2.10.eps generated using R-2.10 on his desktop
  (the EPS file with fast rendering)

volc2.13.eps generated using R-2.13 on his laptop
  (the EPS file with slow rendering)

I have viewed both files on the same machine, and the
result indeed is that while volc2.10.eps renders very
quickly, volc2.13.eps does render very slowly (painting
in by vertical strips which move jerkily from left
to right). I estimate that 'gv volc2.10.eps' does the
rendering in less than 1 second, while 'gv volc2.13.eps'
takes about 18 seconds.

Comparing the two files, I think I have found the reason.

A 'diff' on the two files shows a basic difference in
definitions of a function used in the plotting:

[A] In file volc2.10.eps (the fast one):

  /rgb { setrgbcolor } def

[B] In file volc2.13.eps (the slow one):

  /srgb { [ /CIEBasedABC
            << /DecodeLMN
                 [ { dup 0.03928 le
                          {12.92321 div}
                          {0.055 add 1.055 div 2.4 exp }
                       ifelse
                   } bind dup dup
                 ]
               /MatrixLMN [0.412457 0.212673 0.019334
                           0.357576 0.715152 0.119192
                           0.180437 0.072175 0.950301]
               /WhitePoint [0.9505 1.0 1.0890]
             >>
           ] setcolorspace } def
  /setrgb { srgb setcolor } def


Then [A] volc2.10.eps (the fast one) uses commands like:

  /bg { 1 0 0 rgb } def

while [B] volc2.13.eps (the slow one) uses commands like:

  /bg { 1 0 0 setrgb } def

in each case for exactly the same purpose. Thus [B] the
slow one uses repeatedly (1157 times) a function setrgb
which has much higher overheads (see definition above)
than the function rgb used (1156 times) by [A] the fast one.

So the difference in performance is *definitely* down to
a specific difference in how R-2.13 implements 'postscript()'
compared with R-2.10.

Hoping this is useful!
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 21-Jul-11                                       Time: 16:26:33
------------------------------ XFMail ------------------------------



More information about the R-help mailing list