Re: [R] latex, eps graphics and transparent colors

From: Thomas Lumley <tlumley_at_uw.edu>
Date: Thu, 14 Apr 2011 08:07:04 +1200

On Thu, Apr 14, 2011 at 5:30 AM, Michael Friendly <friendly_at_yorku.ca> wrote:
> I have a diagram to be included in latex, where all my figures are .eps
> graphics (so pdflatex is not an
> option)

You could use the pdf() device and then use pdf2ps to convert to PostScript.

>and I want to achieve something
> like the following: three concentric filled circles varying in lightness or
> saturation.  It is easiest to do this using
> transparency, but in my test using the postscript driver, the transparent
> color fills do not appear.  Is it
> correct that postscript() does not support transparency?
>
> circle <-function (radius = 1, segments=61) {
>        angles <- (0:segments)*2*pi/segments
>        radius * cbind( cos(angles), sin(angles))
> }
>
> plot(1:5, 1:5, type='n', xlim=c(-1,5), ylim=c(-1,5), xlab='', ylab='',
>        asp=1, xaxt="n", yaxt="n")
>
> #clrs <- trans.colors("lightblue", alpha=c(.2, .4, .6))  ## from heplots

There's now an adjustcolor() function in base R to do this.

> package
> clrs <- c("#ADD8E633", "#ADD8E666", "#ADD8E699")
>
> c1 <- circle(3)
> polygon(    c1, col=clrs[1], border="lightblue")
> polygon(.67*c1, col=clrs[2], border="lightblue")
> polygon(.33*c1, col=clrs[3], border="lightblue")
>
> arrows(-1,  0, 5, 0, angle=10, length=.2, lwd=2, col="darkgray")
> arrows( 0, -1, 0, 5, angle=10, length=.2, lwd=2, col="darkgray")
>
> One alternative that sort of works is to use the png() driver, and then
> convert fig.png fig.eps
> but I need very high resolution to make the real diagram legible.
>
> It might suffice to use hcl() colors to approximate what I've done with
> transparency,
> but I don't know how to start with a given color ("lightblue") and achieve
> roughly
> similar resuts.

It would be useful to have an alpha-blending function for this sort of purpose, but I don't think we have one.

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

______________________________________________
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.
Received on Wed 13 Apr 2011 - 20:10:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 13 Apr 2011 - 21:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive