- commit
- 4ec0dadfd1529e5c51bf5a2e80cf08ae9e7406cc
- parent
- a896283ee9fcd5f906e25ccd5b439b54e2be342f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-08-06 07:58
rework coverage tables
Diffstat
| M | analysis.md | 71 | +++++++++++++++++++++++++++++++++++-------------------------- |
| M | plots/coverage.py | 6 | ++++-- |
2 files changed, 45 insertions, 32 deletions
diff --git a/analysis.md b/analysis.md
@@ -456,50 +456,61 @@ and 75 loosely correspond to 3, 4.5, and 7 in WCAG 2.x. 456 456 457 457 Again I generated random color pairs and used them to compare APCA to WCAG 2.x: 458 458459 -1 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total |460 -1 | ------:| -------:| -------:| ------:| ------:| ------:| ------:| ------:| -------:|461 -1 | < 3 | 35.3\* | 25.0\* | 11.3\* | 1.7 | 0.0 | 0.0 | 0.0 | 73.3 |462 -1 | 3-4.5 | 0.0 | 0.8 | 6.2 | 6.5\* | 0.8 | 0.0 | 0.0 | 14.3 |463 -1 | 4.5-7 | 0.0 | 0.0 | 0.8 | 3.8 | 3.7\* | 0.2 | 0.0 | 8.6 |464 -1 | > 7 | 0.0 | 0.0 | 0.0 | 0.2 | 1.8 | 1.6\* | 0.1\* | 3.8 |465 -1 | total | 35.3 | 25.8 | 18.3 | 12.3 | 6.4 | 1.8 | 0.1 | 83.5\* |-1 459 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total | -1 460 | -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -1 461 | < 3 | 34.8\* | 25.1\* | 11.7\* | 1.5 | 0.0 | 0.0 | 0.0 | 73.0 | -1 462 | 3-4.5 | 0.0 | 0.7 | 6.3 | 6.7\* | 0.9 | 0.0 | 0.0 | 14.5 | -1 463 | 4.5-7 | 0.0 | 0.0 | 0.7 | 3.9 | 3.9\* | 0.2 | 0.0 | 8.7 | -1 464 | > 7 | 0.0 | 0.0 | 0.0 | 0.3 | 1.7 | 1.6\* | 0.2\* | 3.8 | -1 465 | total | 34.8 | 25.8 | 18.6 | 12.3 | 6.5 | 1.8 | 0.2 | 83.9\* | 466 466 467 467 The columns correspond to APCA thresholds, the rows correspond to WCAG 2.x468 -1 thresholds. For example, 6.2 % of the generated color pairs pass WCAG 2.x with-1 468 thresholds. For example, 6.3 % of the generated color pairs pass WCAG 2.x with 469 469 a contrast above 3, but fail APCA with a contrast below 45. 470 470 471 471 The \* indicate cases where both a algorithms agree on a threshold level. The 472 472 cell in the bottom right is the total number of cases where both algorithms 473 473 agree, so it can be seen as an indicator of how similar the algorithms are. 474 474475 -1 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total |476 -1 | ---------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:|477 -1 | < 1.6 | 33.7\* | 0.7 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 34.5 |478 -1 | 1.6-2.5 | 1.5 | 23.5\* | 0.8 | 0.0 | 0.0 | 0.0 | 0.0 | 25.9 |479 -1 | 2.5-3.8 | 0.0 | 1.5 | 15.8\* | 0.2 | 0.0 | 0.0 | 0.0 | 17.5 |480 -1 | 3.8-5.7 | 0.0 | 0.0 | 1.7 | 10.4\* | 0.0 | 0.0 | 0.0 | 12.2 |481 -1 | 5.7-8.7 | 0.0 | 0.0 | 0.0 | 1.7 | 5.7\* | 0.0 | 0.0 | 7.4 |482 -1 | 8.7-13.2 | 0.0 | 0.0 | 0.0 | 0.0 | 0.6 | 1.8\* | 0.0 | 2.4 |483 -1 | > 13.2 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.1\* | 0.2 |484 -1 | total | 35.3 | 25.8 | 18.3 | 12.3 | 6.4 | 1.8 | 0.1 | 91.0\* |485 -1486 -1 The second table compares APCA to a modified WCAG 2.x contrast with a flare487 -1 value of 0.4. The thresholds were derived by applying the normalization steps488 -1 described above to the APCA thresholds. As expected, the difference is reduced489 -1 significantly, though there is still a considerable difference left.-1 475 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total | -1 476 | -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -1 477 | < 3.5 | 34.8\* | 25.7\* | 15.1\* | 4.1 | 0.1 | 0.0 | 0.0 | 79.6 | -1 478 | 3.5-3.5 | 0.0 | 0.1 | 3.5 | 6.5\* | 2.4 | 0.0 | 0.0 | 12.6 | -1 479 | 5.5-6 | 0.0 | 0.0 | 0.1 | 1.7 | 3.3\* | 0.4 | 0.0 | 5.4 | -1 480 | > 8 | 0.0 | 0.0 | 0.0 | 0.1 | 0.8 | 1.4\* | 0.2\* | 2.4 | -1 481 | total | 34.8 | 25.8 | 18.6 | 12.3 | 6.5 | 1.8 | 0.2 | 86.9\* | -1 482 -1 483 The second table again compares APCA to WCAG 2.x, but this time I tweaked the -1 484 thresholds to minimize the difference. This shows that some of the difference -1 485 is caused by the choice of thresholds, not the formula itself. -1 486 -1 487 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total | -1 488 | -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -1 489 | < 1.6 | 33.3\* | 0.7 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 34.0 | -1 490 | 1.6-2.5 | 1.4 | 23.5\* | 0.7 | 0.0 | 0.0 | 0.0 | 0.0 | 25.6 | -1 491 | 2.5-3.9 | 0.0 | 1.6 | 16.8\* | 0.5 | 0.0 | 0.0 | 0.0 | 18.9 | -1 492 | 3.9-6 | 0.0 | 0.0 | 1.1 | 11.2\* | 0.3 | 0.0 | 0.0 | 12.6 | -1 493 | 6-9 | 0.0 | 0.0 | 0.0 | 0.6 | 5.9\* | 0.1 | 0.0 | 6.6 | -1 494 | 9-13 | 0.0 | 0.0 | 0.0 | 0.0 | 0.3 | 1.7\* | 0.0 | 2.0 | -1 495 | > 13 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.1 | 0.2\* | 0.2 | -1 496 | total | 34.8 | 25.8 | 18.6 | 12.3 | 6.5 | 1.8 | 0.2 | 92.5\* | -1 497 -1 498 The third table compares APCA to a modified WCAG 2.x contrast with a flare -1 499 value of 0.4. As expected, the difference is reduced significantly, though -1 500 there is still a considerable difference left. 490 501 491 502 | | < 15 | 15-30 | 30-45 | 45-60 | 60-75 | 75-90 | > 90 | total | 492 503 | -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| -------:| 493 504 | < 15 | 33.6\* | 1.3 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 34.9 |494 -1 | 15-30 | 1.3 | 23.1\* | 1.3 | 0.0 | 0.0 | 0.0 | 0.0 | 25.7 |495 -1 | 30-45 | 0.0 | 1.4 | 16.5\* | 1.1 | 0.0 | 0.0 | 0.0 | 18.9 |496 -1 | 45-60 | 0.0 | 0.0 | 1.2 | 10.4\* | 0.7 | 0.0 | 0.0 | 12.3 |497 -1 | 60-75 | 0.0 | 0.0 | 0.0 | 0.8 | 5.2\* | 0.3 | 0.0 | 6.2 |498 -1 | 75-90 | 0.0 | 0.0 | 0.0 | 0.0 | 0.3 | 1.5\* | 0.0 | 1.8 |-1 505 | 15-30 | 1.2 | 23.2\* | 1.2 | 0.0 | 0.0 | 0.0 | 0.0 | 25.5 | -1 506 | 30-45 | 0.0 | 1.3 | 16.3\* | 1.1 | 0.0 | 0.0 | 0.0 | 18.8 | -1 507 | 45-60 | 0.0 | 0.0 | 1.2 | 10.4\* | 0.9 | 0.0 | 0.0 | 12.5 | -1 508 | 60-75 | 0.0 | 0.0 | 0.0 | 0.8 | 5.4\* | 0.2 | 0.0 | 6.4 | -1 509 | 75-90 | 0.0 | 0.0 | 0.0 | 0.0 | 0.3 | 1.6\* | 0.1 | 1.9 | 499 510 | > 90 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.1\* | 0.1 |500 -1 | total | 34.9 | 25.8 | 18.9 | 12.3 | 6.2 | 1.8 | 0.1 | 90.4\* |-1 511 | total | 34.8 | 25.8 | 18.6 | 12.3 | 6.5 | 1.8 | 0.2 | 90.4\* | 501 512502 -1 The third table compares APCA to itself, but with foreground and background-1 513 The last table compares APCA to itself, but with foreground and background 503 514 switched. WCAG 2.x does not make a difference between foreground and 504 515 background, so this comparison would be pointless there. APCA on the other hand 505 516 uses different exponents for foreground and background. This table shows that
diff --git a/plots/coverage.py b/plots/coverage.py
@@ -3,7 +3,8 @@ import math 3 3 import numpy as np 4 4 5 5 WCAG_LEVELS = [3, 4.5, 7]6 -1 WCAG4_LEVELS = [1.6, 2.5, 3.8, 5.7, 8.7, 13.2]-1 6 WCAG_LEVELS_TWEAKED = [3.5, 5.5, 8] -1 7 WCAG4_LEVELS = [1.6, 2.5, 3.9, 6, 9, 13] 7 8 APCA_LEVELS = [15, 30, 45, 60, 75, 90] 8 9 9 10 @@ -50,7 +51,7 @@ def iter_levels(levels): 50 51 51 52 def print_row(row, sep=' | '): 52 53 _row = [''] + [f'{x:.1f}' for x in row] + ['']53 -1 _row = [f'{s: >5}' for s in _row]-1 54 _row = [f'{s: >7}' for s in _row] 54 55 print(sep.join(_row).strip()) 55 56 56 57 @@ -90,6 +91,7 @@ if __name__ == '__main__': 90 91 91 92 for values1, levels1, values2, levels2 in [ 92 93 (wcag, WCAG_LEVELS, apca, APCA_LEVELS), -1 94 (wcag, WCAG_LEVELS_TWEAKED, apca, APCA_LEVELS), 93 95 (wcag4, WCAG4_LEVELS, apca, APCA_LEVELS), 94 96 (apcai, APCA_LEVELS, apca, APCA_LEVELS), 95 97 ]: