'How to print the confidence interval and data curve via gplot to a high resolution image type in R

I am trying to create high resolution images of my data using R. The loess curve and a semi-transparent confidence interval are printed with gplot. This works. When I put a wrapper around it to print an eps image, I get the following error: "Warning message: In grid.Call.graphics(L_polygon, x$x, x$y, index) : semi-transparency is not supported on this device"

The resulting *.eps image does not have the confidence interval.

I don't necessarily have to stay with gplot. I could also switch to *.tif or another high-resolution image type widely accepted by journal publications. Or I could switch from semi-transparent to a solid CI with the loess curve drawn on top. I've written a number of lines of code toward that last idea, which may eventually work, but am hoping someone knows of a more straight forward solution.

Thanks, Shawna

    ##--- HiRes 
    setwd("C:/temp")
    require(graphics)
    setEPS()
    postscript("tmp.eps", height=8, width=8)

    ##--- Plot and print the curves with their CI's
    p <- qplot(P, D, data=DF, geom=c("smooth"),
            method="loess", formula=y~x,
            group=Solution:TestDate, color=Solution, shape=TestDate,
            xlab="Pressure (mmHg)", ylab="Diameter (mm)"
    )
    p <- p + theme(panel.grid.major = element_blank(), 
            #panel.grid.minor = element_blank(), 
            panel.background = element_blank(), 
            axis.line = element_line(colour = "black"))
    p

    dev.off()


    ##--- Dataframe
    TestDate Solution    P    D
    23-Jul-13    krebs  9.6 1.38
    23-Jul-13    krebs 15.0 1.45
    23-Jul-13    krebs 20.2 1.51
    23-Jul-13    krebs 24.9 1.60
    23-Jul-13    krebs 29.9 1.68
    23-Jul-13    krebs 35.3 1.75
    23-Jul-13    krebs 40.3 1.80
    23-Jul-13    krebs 45.1 1.85
    23-Jul-13    krebs 50.2 1.89
    23-Jul-13    krebs 55.3 1.92
    23-Jul-13    krebs 50.2 1.89
    23-Jul-13    krebs 45.0 1.86
    23-Jul-13    krebs 40.1 1.83
    23-Jul-13    krebs 35.0 1.80
    23-Jul-13    krebs 30.2 1.74
    23-Jul-13    krebs 25.0 1.68
    23-Jul-13    krebs 20.1 1.60
    23-Jul-13    krebs 14.9 1.50
    23-Jul-13    krebs  9.7 1.43
    23-Jul-13    krebs  4.8 1.34
    23-Jul-13      hik 10.2 1.31
    23-Jul-13      hik 15.2 1.35
    23-Jul-13      hik 20.2 1.41
    23-Jul-13      hik 25.2 1.47
    23-Jul-13      hik 30.1 1.52
    23-Jul-13      hik 35.3 1.59
    23-Jul-13      hik 40.2 1.64
    23-Jul-13      hik 45.2 1.75
    23-Jul-13      hik 50.1 1.81
    23-Jul-13      hik 55.0 1.83
    23-Jul-13      hik 50.1 1.80
    23-Jul-13      hik 45.2 1.77
    23-Jul-13      hik 40.2 1.70
    23-Jul-13      hik 35.1 1.62
    23-Jul-13      hik 30.2 1.56
    23-Jul-13      hik 25.0 1.48
    23-Jul-13      hik 20.2 1.42
    23-Jul-13      hik 15.2 1.36
    23-Jul-13      hik 10.2 1.32
    9-Aug-13    krebs  7.5 1.48
    9-Aug-13    krebs 15.0 1.62
    9-Aug-13    krebs 20.1 1.78
    9-Aug-13    krebs 25.1 1.99
    9-Aug-13    krebs 30.1 2.27
    9-Aug-13    krebs 35.1 2.49
    9-Aug-13    krebs 40.0 2.62
    9-Aug-13    krebs 45.0 2.70
    9-Aug-13    krebs 50.0 2.74
    9-Aug-13    krebs 55.0 2.77
    9-Aug-13    krebs 50.0 2.75
    9-Aug-13    krebs 45.1 2.73
    9-Aug-13    krebs 40.0 2.71
    9-Aug-13    krebs 34.9 2.60
    9-Aug-13    krebs 30.0 2.44
    9-Aug-13    krebs 25.1 2.17
    9-Aug-13    krebs 20.1 1.90
    9-Aug-13    krebs 15.1 1.69
    9-Aug-13    krebs  9.8 1.56
    9-Aug-13      hik  9.9 1.41
    9-Aug-13      hik 14.9 1.49
    9-Aug-13      hik 20.0 1.56
    9-Aug-13      hik 25.0 1.69
    9-Aug-13      hik 30.1 1.84
    9-Aug-13      hik 35.3 2.04
    9-Aug-13      hik 40.1 2.29
    9-Aug-13      hik 45.1 2.53
    9-Aug-13      hik 50.0 2.66
    9-Aug-13      hik 55.1 2.73
    9-Aug-13      hik 50.1 2.69
    9-Aug-13      hik 44.9 2.58
    9-Aug-13      hik 40.0 2.37
    9-Aug-13      hik 35.2 2.08
    9-Aug-13      hik 30.1 1.81
    9-Aug-13      hik 24.9 1.61
    9-Aug-13      hik 19.8 1.48
    9-Aug-13      hik 14.6 1.39
    9-Aug-13      hik 10.0 1.32
r


Solution 1:[1]

You can use svg format (scalar vector graphics), which being vectorial always have the highest resolution at each level of zoom and support alpha transparency. Or also a pdf format.

Functions in R are svg(), pdf() which are in the package grDevice you already have in base GNU R.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BBrill