[R] R versions and PostScript files

peter dalgaard pdalgd at gmail.com
Fri Jul 22 10:02:40 CEST 2011


On Jul 22, 2011, at 09:04 , Rainer M Krug wrote:

> On Fri, Jul 22, 2011 at 12:44 AM, Duncan Murdoch
> <murdoch.duncan at gmail.com>wrote:
> 
>> On 11-07-21 5:17 PM, pilchat wrote:
>> 
>>> thank you guys for your reply.
>>> 
>>> i was sure that it was related to changes in the generation of ps
>>> files with the latest R release.
>>> 
>>> now the question is: how can i restore the old behavior in R2.13?
>>> 
>> 
>> Peter told you.
>> 
> 
> True - but editing each file ps won't be an option when creating many ps
> files.
> 

That's not what Peter said.

> A true solution would be to include an optional argument into postscript(),
> e.g. sRGB=TRUE, which uses the old implementation if sRGB==FALSE. Otherwise,
> I do not think there is an *easy* solution, as postscript calls compiled
> code to do the actual work.


The .ps.prolog is not in C code but in an R character vector.

> 
> Cheers,
> 
> Rainer
> 
>> 
>> Duncan Murdoch
>> 
>> 
>> 
>>> thanks
>>> 
>>> gaetano
>>> 
>>> On 7/21/11, Ted Harding<ted.harding at wlandres.**net<ted.harding at wlandres.net>>
>>> wrote:
>>> 
>>>> Yes, Peter, your suggestion does the trick (at any rate with
>>>> Gaetano's files).
>>>> 
>>>> I edited his volc2.13.eps (the slow one) as follows (the original
>>>> commented out with "%%##") making just the following change:
>>>> 
>>>> %%## /setrgb { srgb setcolor } def
>>>> /setrgb { setrgbcolor } def
>>>> %%## End of editing
>>>> 
>>>> (at line 53 of the prologue). The result is a file that produces
>>>> exactly the same picture as the other (fast) one, and renders
>>>> (to within my perceptual resolution) in exactly the same time,
>>>> i.e. just under one second (as opposed to about 18 before).
>>>> 
>>>> Thanks, Peter!
>>>> Ted.
>>>> 
>>>> On 21-Jul-11 18:59:58, peter dalgaard wrote:
>>>> 
>>>>> This is due to the introduction of sRGB. Since this actually does
>>>>> something (Google for sRGB and you will be approximately as wise as
>>>>> me...), I don't think it is likely to be taken out. You can, however,
>>>>> always edit .ps.prolog. (I would expect that the line
>>>>> 
>>>>> /setrgb { setrgbcolor } def
>>>>> 
>>>>> instead of what is already there would reinstate the old behavior, but
>>>>> no guarantees.
>>>>> )
>>>>> 
>>>>> 
>>>>> On Jul 21, 2011, at 17:26 , (Ted Harding) wrote:
>>>>> 
>>>>> 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<ted.harding at wlandres.net>
>>>>>>> 
>>>>>> Fax-to-email: +44 (0)870 094 0861
>>>>>> Date: 21-Jul-11                                       Time: 16:26:33
>>>>>> ------------------------------ XFMail ------------------------------
>>>>>> 
>>>>>> ______________________________**________________
>>>>>> R-help at r-project.org mailing list
>>>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>>>> PLEASE do read the posting guide
>>>>>> http://www.R-project.org/**posting-guide.html<http://www.R-project.org/posting-guide.html>
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>> 
>>>>> 
>>>>> --
>>>>> Peter Dalgaard
>>>>> Center for Statistics, Copenhagen Business School
>>>>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>>>>> Phone: (+45)38153501
>>>>> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
>>>>> 
>>>>> 
>>>> ------------------------------**------------------------------**--------
>>>> E-Mail: (Ted Harding)<ted.harding at wlandres.**net<ted.harding at wlandres.net>
>>>>> 
>>>> Fax-to-email: +44 (0)870 094 0861
>>>> Date: 21-Jul-11                                       Time: 21:13:21
>>>> ------------------------------ XFMail ------------------------------
>>>> 
>>>> 
>>> ______________________________**________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide http://www.R-project.org/**
>>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>> 
>> ______________________________**________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> 
> 
> -- 
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
> UCT), Dipl. Phys. (Germany)
> 
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
> 
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax (F):       +33 - (0)9 58 10 27 44
> 
> Fax (D):    +49 - (0)3 21 21 25 22 44
> 
> email:      Rainer at krugs.de
> 
> Skype:      RMkrug
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list