[R] R plots pdf() does not allow spotcolors?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Apr 13 18:26:57 CEST 2011


2011/4/13 Matthieu Stigler <matthieu.stigler at gmail.com>:
> Jim
>
> Thanks for your feedback! The problem is that the people "those responsible
> for layout" are us... We are doing the book in Latex, and till now did not
> need any other software.
>
> But I am scared we will need use kind of Indesign & co softwares to be able
> to use our R plots, since R can't export into spotcolor...

 I've just had a look into how PostScript handles spot colours, having
been hacking PS files for many years its not something I'd played with
before.

 This page gave me a PS file that used spot colours:

http://pslib.sourceforge.net/examples.php

and it seems that you can set a colour using a colour space array:

    [ /Separation (PANTONE Violet C)
  /DeviceCMYK { dup 0.750000 mul exch dup 0.940000 mul exch dup
0.000000 mul exch 0.000000 mul }
    ] setcolorspace 1.00 setcolor

Now, my screen previewer has no idea what colour PANTONE Violet C is,
so there's an alternative CMYK colour space version. In fact PANTONE
Violet C is just a label. The idea is that when processed for colour
separations the software will use the separation colours.

Now, to get this into R is tricky. Either you have to rewrite the PS
driver or hack the PS output file. I produced a simple R plot with one
purple (col="#FF00FF") blob and saved to a PS file. The bit of the PS
that set the colour was this:

 /bg { 1 0 1 rgb } def
 1 0 1 rgb

 - the two settings here are for the outline and fill of the blob,
which was created using pch=19.

 To specify this as a spot colour (with a CMYK alternative for
preview), I changed that to this:

/pvc {
    [ /Separation (PANTONE Violet C)
  /DeviceCMYK { dup 0.750000 mul exch dup 0.940000 mul exch dup
0.000000 mul exch 0.000000 mul }
    ] setcolorspace
} def

/bg {
pvc 1.00 setcolor
} def
pvc 1.00 setcolor

Now if you only have one or two spot colours and only a few places
where they occur then it might be possible for you to do this kind of
edit/replacement - either manually or automatically. And beware I'm
not even sure this is right or that your publisher would be happy
anyway.

 Anyway, thats enough PS hacking for one day.

Barry



More information about the R-help mailing list