Kierrajames
Kierrajames

Reputation: 21

The axis of ROC multiplot is being weird when saved as pdf in studio

I am new to R and coding. I am trying to save a multiplot as a pdf or a jpeg. But when I do the

knitr::opts_chunk$set(dev = "tiff",
                      dpi = 500)

pdf("ROCplots.pdf")
par(mfrow=c(1,2))

# ROC plot 1
roc(na.exclude(Data$Disease), glmbas$fitted.values, plot=TRUE, legacy.axes=FALSE, percent=TRUE, col="skyblue3", lty="solid", lwd=2, print.auc=FALSE)
plot.roc(na.exclude(Data$Disease),  glmadv$fitted.values, percent=TRUE, col="skyblue3", lty="longdash", lwd=2, print.auc=FALSE, add=TRUE)

legend("bottomright", c("Adv 1 (AUC = 0.89)", "Bas 1 (AUC = 0.81)"),
        col = c("skyblue3", "skyblue3"), lty=c("longdash", "solid"), lwd=2, cex = 0.45)

title(main = "A) Bas-Adv 1", line = 2.5, cex=4)

# ROC plot 2
roc(na.exclude(Data$Disease), glmbas4$fitted.values, plot=TRUE, legacy.axes=FALSE, percent=TRUE, col="skyblue3", lty="solid", lwd=2, print.auc=FALSE)
plot.roc(na.exclude(Data$Disease),  glmadv4$fitted.values, percent=TRUE, col="skyblue3", lty="longdash", lwd=2, print.auc=FALSE, add=TRUE)

legend("bottomright", c("Adv 4 (AUC = 0.83)", "bas 4 (AUC = 0.73)"),
        col = c("skyblue3", "skyblue3"), lty=c("longdash", "solid"), lwd=2, cex = 0.45)

title(main = "B)Bas-Adv 4", line = 2.5, cex=4)


dev.off()

It comes out with weird axes. Please see in the attached image. I have tried everything recommended online. I have played with height and width and still the axis are wrong. I want the axis to be : x= 100 to 0 with 20 as the gap between the points (Specificity %); the y-axis to be = 0 to 100 with 20 as the gap. enter image description here

In the code itself, the plots turn out fine. Please see the attached screenshot.enter image description here They get wonky when I save them as a pdf or jpeg.

I would really appreciate the help. also how can I set the pdf image width to 255 pts.

Upvotes: 0

Views: 27

Answers (0)

Related Questions