I am generating and saving an EMF file with ggplot2 and with the win开发者_C百科.graph command. the output graph is low quality and lines looked jagged. I really need to have it in EMF format (exporting to pdf solves the problem but I need the EMF file). How can I make it high quality? (the emf output is here in case you like to see it)
require(ggplot2)
my.dates = as.Date(c("2011-07-22","2011-07-23",
"2011-07-24","2011-07-28","2011-07-29"))
my.vals = c(5,6,8,7,3)
my.data <- data.frame(date =my.dates, vals = my.vals)
plot(my.dates, my.vals)
p <- ggplot(data = my.data, aes(date,vals))+ geom_line(size = 1.5)
p <- p + scale_x_date(format="%m/%d", ' ')
win.graph(width=860/72, height=450/72,pointsize = 12)
print(p)
savePlot("c:/test.emf",type="emf")
dev.off()
EMF is vector based. I was pasting the EMF files into powerpoint slides and I noticed that they are rendered as low res. If you right click on the EMF file and select edit photo it will render it properly. That solved my problem.
Update: I went ahead and wrote a little VBA script that ungroups the EMF file. It breaks it into a graph object that can be easily scaled. It looks very nice now.
You can save your ggplot as SVG and then post-process it with Inkscape. It's easy to use, free and gives great results.
精彩评论