I have to submit figures generated with pROC package to a journal that requires editable figures (in .svg or .ai formatting specifically). Until now, I have just been right clicking on the figure as it is generated and saving it as .png. Unfortunately, this will not do for the journal. Here is my code:
library(pROC)
par(pty="s")
r_lda = roc(crs$CRS, crs$tbscore_corr_lda_inv_crs)
r_cf1 = roc(crs$CRS, crs$cf1_inv)
r_cf3 = roc(crs$CRS, crs$cf3_inv)
r_gbp5 = roc(crs$CRS, crs$gbp5_inv)
r_dusp3 = roc(crs$CRS, crs$dusp3_inv)
multiple <- plot.roc(r_lda, print.auc=TRUE, auc.polygon=TRUE, auc.polygon.col = "#FFEBEE",print.thres=FALSE,
col=pal_pro[1], print.auc.y=0.50, print.auc.x=0.40, xlim = c(1.1,0))
multiple <- plot.roc(r_cf1, print.auc=TRUE, auc.polygon=FALSE,col=pal_pro[2], add=TRUE, print.auc.y=0.40, print.auc.x=0.40, xlim = c(1.2,0), ylim = c(0,1.2))
multiple <- plot.roc(r_gbp5, print.auc=TRUE, auc.polygon=FALSE,col=pal_pro[3], add=TRUE, print.auc.y=0.30, print.auc.x=0.40, xlim = c(1.2,0), ylim = c(0,1.2))
multiple <- plot.roc(r_dusp3, print.auc=TRUE, auc.polygon=FALSE,col=pal_pro[4], add=TRUE, print.auc.y=0.20, print.auc.x=0.40, xlim = c(1.2,0), ylim = c(0,1.2))
legend("bottom",
legend=c("TB score", "KLF2", "GBP5", "DUSP3"),
col=pal_pro,
lwd=6, cex =0.5, xpd = TRUE, horiz = TRUE)
text(0.2, 0.65, "TB score",col=pal_pro[1], font=2)
text(0.5, 0.45, "KLF2",col=pal_pro[2])
text(0.8, 0.7, "GBP5",col=pal_pro[3])
text(0.55, 0.9, "DUSP3",col=pal_pro[4])
Would you be able to provide some advice on how to save this in an editable format?
I have tried using ggsave() with device = "svg" specified but it returns the following error:
"Error in UseMethod("grid.draw") :
no applicable method for 'grid.draw' applied to an object of class "roc""
Other than that, other solutions required me changing the plot itself which at this point I am unable to do.
Use the
svglitepackage to write your plot to ansvgfile. Eg:Note
svglitecreates much better editable svg files than the regular Rsvgdevice. If you compare the files created with each you'll see the difference.