Commit 95e31c6
committed
perf(legend): skip the categorical legend past scanpy's color-palette limit
Coloring by a high-cardinality categorical (e.g. Xenium points by gene, ~3000
genes) spent ~10s building the legend: scanpy's _add_categorical_legend adds one
autoscaling artist per category, so matplotlib re-autoscales O(categories^2)
(sticky_edges called ~categories^2 times). Past len(default_102)=102 categories
scanpy already colors every point uniform grey, so a per-entry legend carries no
information anyway. Skip it with a warning above that limit (tied to scanpy's
palette so the two stay in sync). 2M points x 3085 genes: 16.9s -> 6.5s.1 parent 21c1796 commit 95e31c6
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
447 | 448 | | |
448 | 449 | | |
449 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
450 | 458 | | |
451 | 459 | | |
452 | 460 | | |
| |||
498 | 506 | | |
499 | 507 | | |
500 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
501 | 517 | | |
502 | 518 | | |
503 | 519 | | |
| |||
0 commit comments