0

I'm trying to add a specific point to my ROC curve using:

g <- ggroc(c.roc, size = 0.8) + 
  labs(x="specificities", y = "sensitivities")

g  + ggplot(tibble(sensitivities=3.9558923, specificities=0.8552395), aes(x=sensitivities, y=specificities)) +
  geom_point(colour="blue")

but doesn't work:

Error: Don't know how to add ggplot(tibble(sensitivities = 3.9558923, specificities = 0.8552395), aes(x = sensitivities, y = specificities)) to a plot

RLave
  • 8,144
  • 3
  • 21
  • 37
LaiaEC
  • 1
  • 1
  • 2
    Why do you have #c in your title? Also, please specify the data and packages you've used. Please see [this](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for some guidance. – David Arenburg May 22 '19 at 11:17

1 Answers1

0

What you've done is ggroc() + ggplot() + geom_point(), which is essentially ggplot() + ggplot() + geom_point(). Much like ggplot, ggroc expects a geom layer, and not another data layer. To add new data you can pass it into your geom. This should work:

g <- ggroc(c.roc, size = 0.8) +
    labs(x="specificities", y = "sensitivities")

# You don't need ggplot. Just pass data into your geom.
g + geom_point(data = tibble(sensitivities=0.9558923, # Should be less than one.
                             specificities=0.8552395
                             ),
               mapping = aes(x=sensitivities, y=specificities),
               colour = "blue")

Just make sure colour is outside of aes. Also note that ROC x and y scales are 0 to 1, which means a sensitivities = 3.9558923 will put the point outside of the plotting area. I've changed it to 0.9558923 above.

  • I have tryed and the point doesn't appear and R return: Warning message: Removed 1 rows containing missing values (geom_point). – LaiaEC May 22 '19 at 13:10
  • @LaiaEC ROC plots use x and y scales between 0 and 1, which means `sensitivities=3.9558923` will put the point outside of plotting area. –  May 22 '19 at 13:59