2015-07-12 28 views
0

grDevices R函數cairo_pdfcairo_ps中提到當在矢量輸出中使用透明度(alpha通道)時,它將在a處柵格化PDF或postscript導出圖形72 dpi的分辨率: https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/cairo.htmlR:在cairo_pdf和cairo_ps中使用大於72dpi的cairo回退分辨率

你可以看到這個問題,如果你嘗試

library(ggplot2) 
cairo_ps(file = "test.eps",onefile = FALSE) 
qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width, alpha = I(0.7)) 
dev.off() 

在輸出(這裏放大)的繪圖符號都嚴重像素化的話,顯示它確實只用72 dpi: enter image description here

我想知道如何將回退分辨率提高到600 dpi? 在library(RGtk2)有一個命令cairoSurfaceSetFallbackResolution,我認爲這是什麼在這裏相關,但我不知道如何使grDevices使用該參數。有什麼想法嗎?

使用postscript() btw也不起作用,因爲它不支持透明度,並返回錯誤「此設備不支持半透明度:每頁僅報告一次」。

回答

0

最新的r-devel版本現在增加了額外的參數fallback_resolution來指定不支持的矢量元素應該被光柵化的分辨率,例如, :

library(ggplot2) 
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()