2.7 Covrank right

R figure

Code
h <- 500 
w <- 500 

grid.step <- 50


plot( c(0,w), c(0,h),  
     xaxs = "i",yaxs = "i",
     xaxt = 'n', yaxt = 'n',
     type = "n",
     xlab = "Negatives", ylab = "Positives")
     
x <- c(0,  50,  100,  500)
y <- c(0, 200,  300,  500)

axis(2,y,labels=c('0','TP1','TP2','Pos'))
axis(1,x,labels=c('0','FP1','FP2','Neg'))

gx <- grid.step
while (gx <= w) {
  abline(v = gx, col="gray", lty="dotted")
  gx <- gx + grid.step
}
gy <- grid.step
while (gy <= h) {
  abline(h = gy, col="gray", lty="dotted")
  gy <- gy + grid.step
}

text( x[1]+10, y[1]+10, "A")
text( x[2:3]+10, y[2:3], labels=c("B","C"))
text( x[4]-10, y[4]-15, "D")

for (i in 2:3) {
  abline(v=x[i],lty='dashed')
  abline(h=y[i],lty='dashed')
}

lines( x, y, lty=1, type='o')

Python figure

Code
import matplotlib.pyplot as plt

h = 500
w = 500
grid_step = 50

fig, ax = plt.subplots()
ax.set_xlim(0, w)
(0.0, 500.0)
Code
ax.set_ylim(0, h)
(0.0, 500.0)
Code
ax.set_xticks([0, 50, 100, 500])
ax.set_xticklabels(['0', 'FP1', 'FP2', 'Neg'])
ax.set_yticks([0, 200, 300, 500])
ax.set_yticklabels(['0', 'TP1', 'TP2', 'Pos'])

x = [0, 50, 100, 500]
y = [0, 200, 300, 500]

for gx in range(grid_step, w + 1, grid_step):
    ax.axvline(x=gx, linestyle='dotted', color='gray')
for gy in range(grid_step, h + 1, grid_step):
    ax.axhline(y=gy, linestyle='dotted', color='gray')

ax.text(x[0]+10, y[0]+10, "A")
ax.text(x[1]+10, y[1], "B")
ax.text(x[2]+10, y[2], "C")
ax.text(x[3]-10, y[3]-15, "D")

for i in [1, 2]:
    ax.axvline(x=x[i], linestyle='dashed', color='black')
    ax.axhline(y=y[i], linestyle='dashed', color='black')

ax.plot(x, y, linestyle='solid', marker='o', color='black')
ax.set_xlabel("Negatives")
ax.set_ylabel("Positives")
plt.show()