1

Well, i've been trying to make a plot with my ROCS in a particular fashion so it matches the style of publications my colleagues are doing.

Example of what i want to get

But everytime i do my ROCS i cant even manage to reduce my axis, ( i tried several changes in xlim), nor i obtain the "box-like" border of the graphs. I tried following these tutorials

https://www.youtube.com/watch?v=qcvAqAH60Yw https://rdrr.io/cran/pROC/man/ggroc.html

but i dont obtain anything, and ggroc refuses to works saying my dimensions are not correct (Even with the example provided by the page).

I just obtained this with my data:

enter image description here

But if i change my xlim to 0,1

enter image description here

Doesnt work. And i have tried several combinations of it.

Any ideas?

In order to provide some code, lets work with ASAH data.

enter image description here

And we get the same problems with the plot in pROC if we do it.

enter image description here

Could you lend me a hand with this, honorable community of stack? Edit: So far, so good with this. But i still have the problems of the axis, wich i want them to start as the first image as reference that i posted.

With ggplot2 i think i cand do it, tho, thanks to an answer provided.

enter image description here

Galpaccru
  • 57
  • 12
  • 2
    This should answer your question [pROC ROC curves remove empty space](https://stackoverflow.com/questions/42057979/proc-roc-curves-remove-empty-space) – Calimo Apr 09 '20 at 05:51
  • If not then please edit this one to highlight what is still unclear. – Calimo Apr 09 '20 at 05:52
  • Very useful, but i still got that tiny space between my "function" (roc) and the axis. ¿Is there a way i can force it as my first image? @Calimo – Galpaccru Apr 12 '20 at 14:13
  • Please edit your question with what you have now. – Calimo Apr 12 '20 at 14:44
  • Also I don't see why you tagged the question with ggplot2. Can you clarify that too? Do you specifically want an answer with ggplot2? – Calimo Apr 12 '20 at 14:45
  • Not really, i just see that is the most common library for plots and i just tagged it, my bad. Will edit in a minute, i just re-run my rmd and everything went bollocks, every number changed despise my set.seed. – Galpaccru Apr 12 '20 at 14:55
  • Done, @Calimo. Thanks in advance :D. I think i can do it with ggplot2, but im in the procces of doing it – Galpaccru Apr 12 '20 at 15:35

1 Answers1

5
library(ggplot2)
library(pROC)

#some data
data(aSAH)

# store roc object 
roc.ob <- roc(outcome ~ s100b, aSAH)

ggroc(roc.ob, legacy.axes = T) +
geom_abline(slope = 1 ,intercept = 0) + # add identity line
theme(
panel.background = element_blank(), 
axis.title.x = element_text(size =18, face = 'bold'),
axis.title.y = element_text(size =18, face = 'bold'),
panel.border = element_rect(size = 2, fill = NA), 
axis.text.x = element_text(size = 14, face ='bold'),
axis.text.y = element_text(size = 14, face ='bold')) +
xlab('100% - Specificity') +
ylab('100% - Sensitivity') +
scale_x_continuous(breaks = seq(0,1,0.25), labels = seq(0,1,0.25) * 100) + 
scale_y_continuous(breaks = seq(0,1,0.25), labels = seq(0,1,0.25) * 100)
e.matt
  • 836
  • 1
  • 5
  • 12
  • This works quite fine, thank you. There still a problem with the x.axis values, because we say 100%-specificity and it keeps starting at 100. ¿Is there a way i can change that? ¿Is there a way i can plot the AUC value in the same plot? Or even plotting various ROCS there?. Im looking for tutorials on ggplot themes :D, seems quite useful. @e.matt – Galpaccru Apr 09 '20 at 17:23
  • Updated with axes work around which may help – e.matt Apr 13 '20 at 10:41
  • Thank you ! Had to adapt the code to: scale_x_continuous(breaks = (seq(0,1,0.25)*100)-100, labels = seq(0,1,0.25) * 100) + scale_y_continuous(breaks = seq(0,1,0.25)*100, labels = seq(0,1,0.25) * 100) But now it works perfectly! @e.matt – Galpaccru Apr 13 '20 at 12:47