[R] Legend symbols mixed char and integer

Mike Prager mike.prager at mhprager.com
Sun Nov 28 20:51:25 CET 2010


On Sun, 28 Nov 2010 07:54:43 +0000 (GMT), Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:

>On Sat, 27 Nov 2010, Mike Prager wrote:
>
>> I need to generate a plot with both open and filled circles. It is
>> simple enough, using pch=1 and pch=16.
>>
>> The R pdf graphics output is going into pdftex 1.40.10 (MikTeX 2.8).
>>
>> The R pdf is correct when viewed in other viewers. However, pdftex
>> fills the open circles.  I can work around this problem by using
>> pch="o" for the open circles. However, that messes up the figure
>> legend.
>>
>> Is it possible to use the pch argument of legend() to specify both a
>> symbol number and a character? I haven't found the way.
>
>You don't need to.  pch="o" is the same as pch=111 (the ASCII number). 
>See ?points.
>
>> Or is there some known work-around for the pdftex bug?
>
>Well, pdftex is not a viewer and does not of itself process PDF 
>inclusions, but see ?pdf and the 'useDingbats' argument.
>
>If you really think this is a bug in your LaTeX system, you should 
>report it.  But you haven't shown us reproducible code, and similar 
>things have worked for me in the past.

Many thanks to Brian R. I obtained the desired plot by using
'useDingbats = FALSE',  after switching from 'savePlot' to
'dev.copy2pdf', which allows that argument.

Thanks especially for the reference to 'points'. Though I had looked
several other places for a mapping of 'pch' to characters, I hadn't
thought of looking there.

To clarify, I doubt that this is an R bug.  The PDF displays wrong
only when it goes through pdftex. I am not knowledgable enough about
pdf or epstex to trace the error's origin.

If it would help anyone, I will attempt later to develop simple
reproducible code demonstrating this.

--
Mike Prager, NC, USA 
(Remove pi from email to use)



More information about the R-help mailing list