-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvexhull_left.qmd
71 lines (56 loc) · 1.94 KB
/
convexhull_left.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: "Convexhull right"
---
```{r}
#| echo: false
# Data definition
ranking <- c(1, 1, 1, 0, 1, 0, 0, 1, 0, 0)
x <- c(0, 0, 0, 300, 300, 300, 600, 600, 600, 900, 1200)
y <- c(0, 200, 400, 400, 600, 800, 800, 1000, 1200, 1200, 1200)
# Plot dimensions
h <- 1200 # height of plot
w <- 1200 # width of plot
grid.step <- 120 # step for the grid
# Initialize the plot
plot(
c(0, w), c(0, h),
xaxs = "i", yaxs = "i", # Inner plotting area
xaxt = 'n', yaxt = 'n', # Suppress default axes
type = "n", # Empty canvas
xlab = "False positive rate",
ylab = "True positive rate"
)
# Draw axes with custom labels
axis(1, at = seq(0, w, length.out = length(x)),
labels = c('', '', '', '0.25', '', '', '0.50', '', '', '0.75', '1.00'))
axis(2, at = seq(0, h, length.out = length(y)),
labels = c('', '0.17', '0.33', '', '0.50', '0.67', '', '0.83', '1.00', '', ''))
# Add a grid
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
}
# Draw curve connecting points
lines(x, y, lty = 3, type = 'o') # 'o' for points and lines
# Draw convex hull segments
segments(x[1], y[1], x[3], y[3], lty = 1, lwd = 4, col = "red")
segments(x[3], y[3], x[9], y[9], lty = 1, lwd = 2, col = "red")
segments(x[9], y[9], x[11], y[11], lty = 1, lwd = 4, col = "red")
# Optionally draw descending diagonal (commented for now)
#abline(c(1200, -h / w), lty = 3, col = "blue")
#segments(0, 960, 240, 960, lty = 3, col = "blue")
#segments(0, 12000 / 14, 4800 / 14, 12000 / 14, lty = 3, col = "blue")
# Add point labels (optional, uncomment if needed)
# text(x[4] + 10, y[4] - 15, "A", col = "red")
# text(x[6] + 10, y[6] - 15, "B", col = "red")
# text(x[9] + 10, y[9] - 15, "C", col = "red")
# Save to a file (optional, uncomment to enable)
# png(height = h, width = w, filename = "pn-nested.png")
# dev.off()
```