How do I plot ROC curves with binary predictions? Here is a simple dataset of actual and predicted results, with the resulting error matrix.  How do I plot an ROC curve with this?  I don't understand why the curve is not just four ordered pairs.  Thank you!
df <- data.frame(actual=c(0,0,0,0,0,0,0,1,1,1), predicted=c(0,0,0,0,0,1,1,1,1,1), 
        result=c("True Positive", "True Positive", "True Positive", "True Positive", "True Positive", 
           "False Negative", "False Negative", "True Negative", "True Negative", "True Negative"))
table(df[,3])

False Negative False Positive  True Negative  True Positive 
             2              0              3              5

 A: In the general case: you can't
The ROC curve shows how sensitivity and specificity varies at every possible threshold. Binary predictions, where predictions have been thresholded already, or a contingency table, have lost information about the other thresholds. Therefore you can't calculate the ROC curve from this summarized data.
But my classifier is binary, so I have one single threshold
Binary classifiers aren't really binary. Even though they may expose only a final binary decision, all the classifiers I know rely on some quantitative estimate under the hood.

*

*A binary decision tree? Try to build a regression tree.

*A classifier SVM? Do a support vector regression.

*Logistic regression? Get access to the raw probabilities.

*Neural network? Use the numeric output of the last layer instead.

This will give you more freedom to choose the optimal threshold to get to the best possible classification for your needs.
But I really want to
You really shouldn't. ROC curves with few thresholds significantly underestimate the true area under the curve (1). A ROC curve with a single point is a worst-case scenario, and any comparison with a continuous classifier will be inaccurate and misleading.
Just give me the answer!
Ok, ok, you win. The easiest is to use one of the many libraries that provide ROC analysis. Here is an example with pROC (that I am authoring), but there are many others:
library(pROC)
plot(roc(df$actual, df$predicted))

If you want to do it manually, you can assume you have a single threshold to calculate:
tn <- sum(df$result == "True Negative")
tp <- sum(df$result == "True Positive")
fn <- sum(df$result == "False Negative")
fp <- sum(df$result == "False Positive")

specificity <- tn / (tn + fp)
sensitivity <- tp / (tp + fn)

And then we can add "pseudo" thresholds at -Inf and +Inf, and plot:
sensitivities <- c(0, sensitivity, 1)
specificities <- c(1, specificity, 0)
plot(1 - specificities, sensitivities, type="l")

To conclude
You can technically plot a ROC curve for a binary classifier from the confusion matrix. But just in case I wasn't clear, let me repeat one last time: DON'T DO IT!
References
(1) DeLong ER, DeLong DM, Clarke-Pearson DL: Comparing the Areas under
Two or More Correlated Receiver Operating Characteristic Curves: A Nonparametric Approach. Biometrics 1988,44:837-845.
https://www.jstor.org/stable/2531595
A: You don’t plot a ROC curve from that information. ROC has to do with predicted probabilities and class to which subjects (photos, whatever) are assigned as you vary the cutoff threshold, not the accuracy or confusion matrix at any particular threshold.
A: To plot the ROC curve you'd have to work with the raw score values:

*

*vary the threshold at which you'd predict either a 0 or 1

*At different thresholds compute the true positive rate (TPR) and false positive rate (FPR)

*Plot TPR vs FPR

