最佳答案
I want to save a stacked area plot (Plot example with code can be found here) made with ggplot2 as SVG. Tried it with the Cairo package but the outcome is bad.
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()