Reputation: 233
I am trying to plot a ROC curve graph using pyhton matplotlib library. I want to display the curve line as a dish line with a marker as the one showed in the picture below: Figure Ref: https://www.biorxiv.org/content/10.1101/2019.12.21.885491v1.full
This is my code:
plt.figure(figsize=(7,7))
fpr, tpr, thresholds = metrics.roc_curve(test_Y, predict_proba)
auc = roc_auc_score(test_Y,y_pred)
plt.plot(fpr, tpr, label='%s (AUC = %0.2f)' % ("LR", auc),marker='h',linestyle='--')
plt.plot([0, 1], [0, 1],'r--',label='No skills')
plt.xlim([-0.02, 1])
plt.ylim([0, 1.02])
plt.xlabel('False Positive Rate (%)')
plt.ylabel('True Positive Rate (%)')
plt.title('ROC Curve')
plt.legend(loc="lower right")
plt.grid()
This is the plot that I have got:
It seems as if something went wrong as the 'marker' printed on the whole line. If I removed the marker parameter from the plot function, I got this:
I do not really know why this might happen. Is is something wrong with the way I plotted the graph, or it might be the issue with the model results.
Could anyone please help me out with this.
Upvotes: 0
Views: 1168
Reputation: 15071
Markers are used at every data point passed in. Do you want to plot the whole curve but display markers at only every e.g. 10 points? If so try this:
plt.plot(fpr, tpr, linestyle='--')
plt.plot(fpr[::10], tpr[::10], marker='h')
Upvotes: 2