r - Can transparency be used with PostScript/EPS? -


i trying save r plot eps file have problem following component of plot - gray transparent polygon (transparent black = gray effect):

polygon(x.polygon, y.polygon.6, col="#00000022", border=na) 

this line of code works fine when saving plot pdf not eps. looks eps not support transparency? other choice have?

here code full plot:

postscript(file="figure.eps", width=5.5, height=5.5, onefile=f, horizontal=f)  ts(t(data.frame(initial_timepoint, second_timepoint, third_timepoint, final_timepoint)))->obj obj[,-c(3,7)]->obj1 plot(obj1, plot.type="single", lwd=0.6, xaxs="i",yaxs="i",xlab="",ylab="lv ejection fraction (%)",xaxt='n',yaxt='n',ylim=c(0,70),col="black") axis(1, at=c(1,2,3,4), labels=c("1","2","3","4"),cex.axis=1) axis(2, at=seq(0,70,10), labels=c("0%","10%","20%","30%","40%","50%","60%","70%"),cex.axis=1, las=1) abline(v=c(2,3),lwd=0.6,lty=2)  stderr <- function(x) sqrt(var(x,na.rm=true)/length(na.omit(x))) avg<-c(mean(initial_timepoint,na.rm=t), mean(second_timepoint,na.rm=t), mean(third_timepoint,na.rm=t), mean(final_timepoint,na.rm=t)) err<-c(stderr(initial_timepoint), stderr(second_timepoint), stderr(third_timepoint), stderr(final_timepoint))  my.count <- c(1,2,3,4) my.count.rev <- c(4,3,2,1) y.polygon.6 <- c((avg+err*1.96)[my.count],(avg-err*1.96)[my.count.rev]) x.polygon <- c(my.count, my.count.rev) polygon(x.polygon, y.polygon.6, col="#00000022", border=na) lines(avg,col="black",lwd=0.8,lty=3) lines((avg+err*1.96),lwd=0.8,lty=3) lines((avg-err*1.96),lwd=0.8,lty=3)  dev.off() 

although eps format not natively support semi-transparency, still possible use cairo_ps(), 1 automatically rasterizes semi-transparent areas, , resolution @ can controlled argument fallback_resolution :

cairo_ps(file = "test.eps", onefile = false, fallback_resolution = 600) qplot(sepal.length, petal.length, data = iris, color = species, size = petal.width, alpha = i(0.7)) dev.off() 

all non-semi-transparent areas nicely stay vector graphics.

or shorter can use :

ggsave("filename.eps", device=cairo_ps, fallback_resolution = 600) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -