我想保存使用ggplot2作为SVG制作的堆叠区域图(可以在此处找到带有代码的绘图示例) 。尝试使用Cairo 套餐,但结果很糟糕。
library(ggplot2)
library(grid)
library(Cairo)
...
#png(output_file, width=800, height=400)
Cairo(800,400,file=paste(output_file, ".svg", sep=""),type="svg",bg="transparent",pointsize=8, units="px",dpi=400)
gt <- ggplot_gtable(ggplot_build(p))
gt$layout$clip[gt$layout$name=="panel"] <- "off"
grid.draw(gt)
dev.off()