[R] postscript (eps) / latex / par(mfg=...) / problem!
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Tue Apr 26 22:32:55 CEST 2005
This problem was aired in October 2003 (see archives).
Brian Ripley explained where it comes from.
Na Li suggested the following:
On 8 Oct 2003, maechler at stat.math.ethz.ch uttered the following:
>>> When I create EPS files, they sometimes appear rotated
>>> in my LaTeX PDF document and sometimes they don't. Two
>>> examples:
>
> It's definitely unrelated to R.
>
> The "bug" is in newer versions of gs (ghostscript) which does
> rotate plots under some circumstances by default.
>
> Of course, the authors of gs consider this a feature (called
> "AutoRotatePages"), but IMO it's been a very bad design-decision.
>
> Here, we have implemented a workaround by patching the
> "epstopdf" (shell script) (we use the version from teTeX), by
> the following:
Another, perhaps easier fix is to define
export GS_OPTIONS="-dAutoRotatePages=/None"
(or its equivalent in tcsh).
Michael
============================================================
On 26-Apr-05 Dan Bolser wrote:
>
> Should I post this to 'bugs'?
>
> On Tue, 26 Apr 2005, Dan Bolser wrote:
>
>>
>>The same problem I am having has been reported here
>>
>>http://tolstoy.newcastle.edu.au/R/devel/04a/0344.html
>>
>>
>>Namely that using par(mfg=...) with a postscript (eps) for inclusion
>>with
>>latex makes the figure appear upside down and back to front (flipped)!
>>
>>Converting the dvi to ps makes matters worse (the eps seems to be
>>broken),
>>however, it appears fine with gv.
>>
>>Here is (basically) the code I am using...
>>
>>>dat <- read.table("x.dmp", header=1)
>>>t(dat)
>>t(dat)
>> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
>>CHAINS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 20 23 24 26 28
>>FREQUENCY 886 792 136 201 16 58 6 21 3 9 3 9 1 4 3 1 1 1 1 1
>>>
>>>postscript(
>>+ "x.eps",
>>+ width = 6.0,
>>+ height = 6.0,
>>+ horizontal = FALSE,
>>+ onefile = FALSE,
>>+ paper = "special",
>>+ )
>>>
>>>par(mfg=c(1,1))
>>>par(mar=c(3,4,1,2))
>>>plot(dat,type='b')
>>>
>>>par(mfg=c(2,1))
>>>par(mar=c(4,4,0,2))
>>>plot(dat,type='b', log='y')
>>>
>>>dev.off()
>>
>>
>>Including the resulting file in a latex document like this...
>>
>>begin{figure}
>>\centering
>>\includegraphics[width=\textwidth]{x.eps}
>>\caption[X]
>>{
>>Hello!
>>}
>>\label{xFig}
>>\end{figure}
>>
>>The result is an upside down (flipped) version of my plot. I tried
>>rotating 180 degrees (based on similar problems people were having on
>>the
>>list), but then it just gets worse (most of the plot is off the page).
>>If
>>I convert the dvi to ps (dvips -Ppdf my.tex.dvi -o my.tex.ps) it gets
>>worse (a tiny speck where the image should be).
>>
>>After removing the two mfg commands (which I use to add grid lines (not
>>shown for clarity)) everything is fine! Some how mfg is snarling things
>>up.
>>
>>OK, I just had a brain wave (dont laugh). Here is a diff of the working
>>eps vs the broken eps...
>>
>>diff broken working
>>
>>78a79,80
>>> %%Page: 1 1
>>> bp
>>229c231
>>< 57.60 43.20 403.20 201.60 cl
>>---
>>> 57.60 57.60 403.20 216.00 cl
>>417c419
>>< %%Pages: 0
>>---
>>> %%Pages: 1
>>
>>
>>Does that help anyone debug my problem? Like I said, both look
>>identical
>>via gv, and are 'conceptually' identical in R.
>>
>>Here are my vitals
>>
>>Linux 2.4.20-31.9 i686 athlon i386 GNU/Linux
>>R 2.0.0 (2004-10-04).
>>GNU Ghostscript 7.05 (2002-04-22)
>>
>>Anything else you need?
>>
>>Please help!
>>
>>______________________________________________
>>R-help at 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
>>
>
> ______________________________________________
> R-help at 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
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 26-Apr-05 Time: 20:07:28
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list