[R] malformed plot symbols in lattice pdf

Dieter Menne dieter.menne at menne-biomed.de
Fri Mar 13 20:43:40 CET 2009


Mark Wilkinson <wilkinsonmr <at> gmail.com> writes:

> I'm using panel.polygon inside a custom panel function to generate
> filled polygons for an xyplot.  Everything is as expected until I
> specify a value < 1 for alpha to fill with a semi-transparent color
> and output to pdf.  The plot symbols appear malformed.  Am I doing
> something wrong here?
> 
> Here is an example (pdfs are attached):
...

I think there is a long-standing problem with pdf (on Windows?). My
workaround for this case:


library(lattice)
library(Cairo)
ex.data <- data.frame(x = sort(runif(10)),
                      y = rnorm(10))

## plot a semi-transparent polygon
ex.panel2 <- function(x, y, alpha) {
    yy.up <- y + 0.25
    yy.lo <- y - 0.25
    panel.polygon(c(x, rev(x)), c(yy.up, rev(yy.lo)),
                  border = NA, col = "lightblue", alpha = 0.5) # note change
    panel.xyplot(x, y, type = "p")
}

## output to pdf (symbols are now malformed)
CairoPDF(file = "plt2.pdf")
#trellis.device(device = pdf, color = TRUE, file = "plt2.pdf")
xyplot(y ~ x, data = ex.data, panel = ex.panel2)
dev.off()




More information about the R-help mailing list