John Kruschke
2011-Jun-23 03:07 UTC
[R] Saved EPS does not match screen when using bquote(.(i))
Here's a fairly minimal-case example in which the saved EPS does not match
the screen. The error comes when using bquote(.(i)) instead of bquote(1), as
demonstrated by the two minimally different cases below. Very strange. Any
clues as to why?
#---------------- begin -------------------
# Version A. X axis labels have subscripts as constants. EPS is correct.
windows()
layout( matrix( 1:2 , nrow=2 ) )
plot( 0 , 0 , xlab=bquote(mu[1]) )
plot( 0 , 0 , xlab=bquote(mu[2]) )
savePlot( file="SavePlotTestA.eps" , type="eps" ) # Axis
labels are correct
in EPS.
# Version B. X axis labels have subscripts as variable index. EPS is wrong!
windows()
layout( matrix( 1:2 , nrow=2 ) )
for ( i in 1:2 ) {
plot( 0 , 0 , xlab=bquote(mu[.(i)]) )
}
savePlot( file="SavePlotTestB.eps" , type="eps" ) # X-AXIS
OF PLOT 1 IS
WRONG IN EPS.
#-------------- end ---------------------
Thanks!
John K. Kruschke, Professor
<http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/>
2011/6/22 Uwe Ligges <ligges@statistik.tu-dortmund.de>
>
>
> On 22.06.2011 13:50, John Kruschke wrote:
>
>> The error happens when using the savePlot() command, like this:
>> savePlot( file="TestSavePlot.eps" , type="eps" )
>> savePlot( file="TestSavePlot.jpg" , type="jpg" )
>>
>
> Well, plot directly into a device, for postscript:
>
> postscript("estSavePlot.eps", additionalArguments .....)
> plot(1:10)
> dev.off()
>
> Uwe Ligges
>
>
> The images in the two saved files are not the same, with the JPG being
>> correct but the EPS being wrong.
>>
>> When you suggest "starting separate devices explicitly", what
do you mean?
>> (I've skimmed through the results of ??device, but can't make
sense of
>> it.)
>> Thank you!
>>
>> John K. Kruschke, Professor
>>
>>
>> 2011/6/22 Uwe
Ligges<ligges@statistik.tu-**dortmund.de<ligges@statistik.tu-dortmund.de>
>> >
>>
>> I guess you use the menu to save the plots from your Windows device
into
>>> files rather than starting separate devices explicitly?
>>> If so, please use explicit calls to the devices and everything
happens as
>>> you define it.
>>>
>>> Uwe Ligges
>>>
>>>
>>>
>>>
>>> On 22.06.2011 04:31, John Kruschke wrote:
>>>
>>> When I save a particular plot as JPG or BMP, the saved image is an
>>>> accurate
>>>> copy of that plot.
>>>> But when I save the same plot as EPS or PDF, some text elements
are
>>>> incorrectly altered.
>>>> An example is attached. Notice in the top middle and top right
panels,
>>>> the
>>>> x-axis labels have correct subscript 1 in the JPG, but
incorrect
>>>> subscript
>>>> 2
>>>> in the EPS.
>>>>
>>>> I'm using R 2.13.0 on Windows 7.
>>>>
>>>> Any clues regarding the source of this error and its solution
would be
>>>> appreciated. For example, are there EPS/PDF device drivers that
need to
>>>> be
>>>> separately updated?
>>>>
>>>> Many thanks.
>>>>
>>>> John K. Kruschke, Professor
>>>>
<http://www.indiana.edu/%****7Ekruschke/****DoingBayesianDataAnalysis/<
>>>>
htt**p://www.indiana.edu/%**7Ekruschke/**DoingBayesianDataAnalysis/<http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/>
>>>> >
>>>>
>>>>
>>>>>
>>>>
>>>>
>>>> ______________________________****________________
>>>> R-help@r-project.org mailing list
>>>>
https://stat.ethz.ch/mailman/****listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>>
<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<http://www.R-project.org/posting-guide.html>
>>>> >
>>>>
>>>> and provide commented, minimal, self-contained, reproducible
code.
>>>>
>>>>
>>>
>>
[[alternative HTML version deleted]]
Dennis Murphy
2011-Jun-23 05:14 UTC
[R] Saved EPS does not match screen when using bquote(.(i))
Hi:
As Uwe suggested...
pdf('testgraph.pdf')
layout( matrix( 1:2 , nrow=2 ) )
for ( i in 1:2 ) {
plot( 0 , 0 , xlab=bquote(mu[.(i)]) )
}
dev.off()
postscript('testgraph.ps')
layout( matrix( 1:2 , nrow=2 ) )
for ( i in 1:2 ) {
plot( 0 , 0 , xlab=bquote(mu[.(i)]) )
}
dev.off()
png('testgraph.png')
layout( matrix( 1:2 , nrow=2 ) )
for ( i in 1:2 ) {
plot( 0 , 0 , xlab=bquote(mu[.(i)]) )
}
dev.off()
The three graphs look the same (although the PS graph is rotated to
landscape while the other two are portrait). The main point is that
mu_1 and mu_2 show up correctly in the two panels in all three graphs
(at least on my viewers).
The following thread from last January describes some of the problems
that certain viewers have with Greek letters, which appear to be
viewer and platform dependent:
http://r-project.markmail.org/search/?q=pdf%20incorrect#query:pdf%20incorrect+page:2+mid:egmb6utulrxgcznw+state:results
I'm guessing that I've seen about a half dozen or so similar posts in
this forum over the past year and a half, so you can check the list
archives for related problems.
HTH,
Dennis
On Wed, Jun 22, 2011 at 8:07 PM, John Kruschke <johnkruschke at gmail.com>
wrote:> Here's a fairly minimal-case example in which the saved EPS does not
match
> the screen. The error comes when using bquote(.(i)) instead of bquote(1),
as
> demonstrated by the two minimally different cases below. Very strange. Any
> clues as to why?
>
> #---------------- begin -------------------
>
> # Version A. X axis labels have subscripts as constants. EPS is correct.
> windows()
> layout( matrix( 1:2 , nrow=2 ) )
> plot( 0 , 0 , xlab=bquote(mu[1]) )
> plot( 0 , 0 , xlab=bquote(mu[2]) )
> savePlot( file="SavePlotTestA.eps" , type="eps" ) #
Axis labels are correct
> in EPS.
>
> # Version B. X axis labels have subscripts as variable index. EPS is wrong!
> windows()
> layout( matrix( 1:2 , nrow=2 ) )
> for ( i in 1:2 ) {
> ?plot( 0 , 0 , xlab=bquote(mu[.(i)]) )
> }
> savePlot( file="SavePlotTestB.eps" , type="eps" ) #
X-AXIS OF PLOT 1 IS
> WRONG IN EPS.
>
> #-------------- end ---------------------
>
> Thanks!
>
> John K. Kruschke, Professor
> <http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/>
>
>
> 2011/6/22 Uwe Ligges <ligges at statistik.tu-dortmund.de>
>
>>
>>
>> On 22.06.2011 13:50, John Kruschke wrote:
>>
>>> The error happens when using the savePlot() command, like this:
>>> savePlot( file="TestSavePlot.eps" , type="eps"
)
>>> savePlot( file="TestSavePlot.jpg" , type="jpg"
)
>>>
>>
>> Well, plot directly into a device, for postscript:
>>
>> postscript("estSavePlot.eps", additionalArguments .....)
>> plot(1:10)
>> dev.off()
>>
>> Uwe Ligges
>>
>>
>> ?The images in the two saved files are not the same, with the JPG being
>>> correct but the EPS being wrong.
>>>
>>> When you suggest "starting separate devices explicitly",
what do you mean?
>>> (I've skimmed through the results of ??device, but can't
make sense of
>>> it.)
>>> Thank you!
>>>
>>> John K. Kruschke, Professor
>>>
>>>
>>> 2011/6/22 Uwe Ligges<ligges at
statistik.tu-**dortmund.de<ligges at statistik.tu-dortmund.de>
>>> >
>>>
>>> ?I guess you use the menu to save the plots from your Windows
device into
>>>> files rather than starting separate devices explicitly?
>>>> If so, please use explicit calls to the devices and everything
happens as
>>>> you define it.
>>>>
>>>> Uwe Ligges
>>>>
>>>>
>>>>
>>>>
>>>> On 22.06.2011 04:31, John Kruschke wrote:
>>>>
>>>> ?When I save a particular plot as JPG or BMP, the saved image
is an
>>>>> accurate
>>>>> copy of that plot.
>>>>> But when I save the same plot as EPS or PDF, some text
elements are
>>>>> incorrectly altered.
>>>>> An example is attached. Notice in the top middle and top
right panels,
>>>>> the
>>>>> x-axis labels have correct subscript 1 in the JPG, but
incorrect
>>>>> subscript
>>>>> 2
>>>>> in the EPS.
>>>>>
>>>>> I'm using R 2.13.0 on Windows 7.
>>>>>
>>>>> Any clues regarding the source of this error and its
solution would be
>>>>> appreciated. For example, are there EPS/PDF device drivers
that need to
>>>>> be
>>>>> separately updated?
>>>>>
>>>>> Many thanks.
>>>>>
>>>>> John K. Kruschke, Professor
>>>>>
<http://www.indiana.edu/%****7Ekruschke/****DoingBayesianDataAnalysis/<
>>>>>
htt**p://www.indiana.edu/%**7Ekruschke/**DoingBayesianDataAnalysis/<http://www.indiana.edu/%7Ekruschke/DoingBayesianDataAnalysis/>
>>>>> >
>>>>>
>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ______________________________****________________
>>>>> R-help at r-project.org mailing list
>>>>>
https://stat.ethz.ch/mailman/****listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>>>
<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<http://www.R-project.org/posting-guide.html>
>>>>> >
>>>>>
>>>>> and provide commented, minimal, self-contained,
reproducible code.
>>>>>
>>>>>
>>>>
>>>
>
> ? ? ? ?[[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.
>