[R-SIG-Mac] [R] Sweave, lty = 3 line incorect in pdf output

Ken Knoblauch ken.knoblauch at inserm.fr
Thu Feb 11 16:01:10 CET 2010


Yes, indeed, I had mentioned before this thread had migrated to r-sig-mac

https://www.stat.math.ethz.ch/pipermail/r-help/2010-February/227847.html

that there is an interaction with the viewer, because I see
a line (though of the wrong width) for a hard copy and
display from imageMagick but no line at all
for Preview and the viewer of TeXShop.  This does not depend
on anti-aliasing being on or off.  I don't have Acroread
on this computer.  Perhaps it is a Leopard issue and I need
to upgrade to Snow Leopard.

The localization to pdf was because I had first noticed this
when using Sweave and Achim suggested trying it with
just the pdf function, which I did, and finding that the "viewed" pdf had
the same problems, on my Mac.

I have the screen resolution set at 1280 x 800 and just tried various
values but it has no effect on the appearance of the line.

Even for the situations in which I can see the line, the lwd argument
does not seem to be respected.  The only situation in which the
output is correct is drawing the graph to a quartz window and
saving it with the SaveAs option from the File menu.
In this case, the Preview viewer and all others display it correctly, too.
I would think that this would argue against it being just the viewer.

One more thing.  I just noticed that the version of the pdf()
generated file is 1.4 but of the version saved from the menu is 1.3.
The sizes differ, too,
71363 (saved from finder) vs 2964 (generated with pdf function),
but lowering the version number when calling pdf doesn't
change anything.

This still leaves the Mac 10.5 vs 10.6 hypothesis (which I cannot
test right away) an open possibility, unless someone has a better
suggestion.

Thank you.

Ken

Quoting Prof Brian Ripley <ripley at stats.ox.ac.uk>:

> Note that pdf does not 'display' anything: it writes a file.  From ?pdf
>
>      If you see problems with PDF output, do remember that the problem
>      is much more likely to be in your viewer than in R.  Try another
>      viewer if possible. ...
>
> So which viewers are you using?
>
> I see no reason why pdf() should produce different output on your Mac
> from anyone else's build of R, and indeed I just ran this on a Mac (R
> 2.10.1, Snow Leopard) and viewed it in Preview and Acroread 9.3.0 with
> no issue. And I transferred the file to Linux and viewed it on several
> PDF viewers there.
>
> One possibility is that this is an issue in Preview only on 10.5.8 (aka
> darwin9.8.0), or it might depend on the screen resolution or just about
> anything else specific to your machine.
>
>
> On Thu, 11 Feb 2010, Ken Knoblauch wrote:
>
>> Achim.
>>
>> Indeed, you are right.  That is where the problem is.
>> Thanks for helping localize it a bit further.
>> So, I should cc this to the r-sig-mac list.
>>
>> For the r-sig-mac list, here is the original post on the r-help
>>
>> https://www.stat.math.ethz.ch/pipermail/r-help/2010-February/227832.html
>>
>> The pdf() command (at least on my Mac :( )  appears to have
>> a problem in displaying dotted lines (lty = 3).
>> Short example,
>>
>> pdf(file = "test.pdf", height = 6, width = 6)
>>
>> x <- 1:10
>> plot(x, type = "l", lty = 3, lwd = 3)
>> lines(x, 0.5 * x, type = "l")
>>
>> dev.off()
>>
>> Hopefully, this is not yet another instance of R-Mac-FAQ 12.10
>> but something more easily treated.
>>
>>
>> R version 2.10.1 Patched (2010-02-01 r51089)
>> i386-apple-darwin9.8.0
>>
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods
>> [7] base
>>
>>
>> loaded via a namespace (and not attached):
>> [1] tools_2.10.1
>>
>> R.app GUI 1.32-dev (5548 Leopard build 32-bit),
>>
>> Thank you.
>>
>> Ken
>>
>> Quoting Achim Zeileis <Achim.Zeileis at uibk.ac.at>:
>>
>>> Ken,
>>>
>>> an idea off-list: Have you tried
>>>
>>> pdf(file = "test.pdf", height = 6, width = 6)
>>> ...
>>> dev.off()
>>>
>>> with your code? This is essentially what Sweave should do internally.
>>> If that replicates your problem, it might be a hint that something with
>>> pdf() is not working on your machine (rather than Sweave()).
>>> Z
>>
>>
>>
>> -- 
>> Ken Knoblauch
>> Inserm U846
>> Stem-cell and Brain Research Institute
>> Department of Integrative Neurosciences
>> 18 avenue du Doyen Lépine
>> 69500 Bron
>> France
>> tel: +33 (0)4 72 91 34 77
>> fax: +33 (0)4 72 91 34 61
>> portable: +33 (0)6 84 10 64 10
>> http://www.sbri.fr/members/kenneth-knoblauch.html
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> 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, UK                Fax:  +44 1865 272595



-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html



More information about the R-SIG-Mac mailing list