Commit b9373c6
committed
refactor(render): single continuous-norm feeds pixels and colorbar (#699)
PR2 of the #699 color/cmap/norm unification. Consolidates the duplicated
"resolve vmin/vmax then map" logic and makes the colorbar derive from the SAME
norm as the pixels, so the two are guaranteed to agree instead of being two
independent computations that happened to match.
Root cause of the latent mismatch: shapes fill is a facecolor-baked
PatchCollection and labels are pre-baked RGB, so matplotlib never maps their
norm — the colorbar range was derived by a separate path (set_clim /
_append_outline_colorbar / the labels imshow norm relying on _map_color_seg
autoscaling the shared norm in place).
- Add `_resolve_continuous_norm(values, cmap_params)`: one pure resolver
(honor explicit vmin/vmax, else finite data range, else [0, 1]). Every
pixel-baking site and its matching colorbar site calls it with the SAME
value vector, so they cannot diverge.
- Fold the 4 duplicated inline norm blocks (`_color_vector_to_rgba` x2,
`_get_collection_shape` x2) into it; drop the now-dead `norm` param of
`_get_collection_shape`.
- Labels: `_map_color_seg` resolves the norm instead of mutating the shared
one; the labels imshow is fed the same resolved norm so its colorbar matches
without the in-place-autoscale side effect.
- Datashader, image, points and graph paths are unchanged (set_array /
reduction bounds — they already share their norm).
Behavior-preserving for normal renders: both old paths already reduced the same
vector to nanmin/nanmax. The resolver adds no vmin==vmax expansion of its own
(matplotlib already expands a degenerate clim by ±0.5 downstream, so the bar is
unchanged; degenerate pixels stay cmap(0) as before). The only edge that
unifies is an all-identical-value outline column, which previously used a
[0, 1] guard — an extreme corner now consistent with the fill path.
Adds unit tests for `_resolve_continuous_norm` and a non-visual integration
test asserting the fill colorbar clim equals the resolved pixel range.1 parent 15fc496 commit b9373c6
4 files changed
Lines changed: 139 additions & 79 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
| |||
80 | 79 | | |
81 | 80 | | |
82 | 81 | | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
515 | | - | |
| 513 | + | |
| 514 | + | |
516 | 515 | | |
517 | 516 | | |
518 | | - | |
519 | | - | |
| 517 | + | |
520 | 518 | | |
521 | | - | |
522 | | - | |
523 | | - | |
| 519 | + | |
524 | 520 | | |
525 | 521 | | |
526 | 522 | | |
527 | | - | |
| 523 | + | |
528 | 524 | | |
529 | 525 | | |
530 | 526 | | |
| |||
963 | 959 | | |
964 | 960 | | |
965 | 961 | | |
966 | | - | |
967 | 962 | | |
968 | 963 | | |
969 | 964 | | |
| |||
982 | 977 | | |
983 | 978 | | |
984 | 979 | | |
985 | | - | |
986 | 980 | | |
987 | 981 | | |
988 | 982 | | |
| |||
1003 | 997 | | |
1004 | 998 | | |
1005 | 999 | | |
1006 | | - | |
1007 | 1000 | | |
1008 | 1001 | | |
1009 | 1002 | | |
| |||
1025 | 1018 | | |
1026 | 1019 | | |
1027 | 1020 | | |
1028 | | - | |
1029 | 1021 | | |
1030 | 1022 | | |
1031 | 1023 | | |
| |||
1038 | 1030 | | |
1039 | 1031 | | |
1040 | 1032 | | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1060 | 1038 | | |
1061 | 1039 | | |
1062 | 1040 | | |
| |||
2460 | 2438 | | |
2461 | 2439 | | |
2462 | 2440 | | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
2463 | 2444 | | |
2464 | 2445 | | |
2465 | 2446 | | |
2466 | 2447 | | |
2467 | | - | |
| 2448 | + | |
2468 | 2449 | | |
2469 | 2450 | | |
2470 | 2451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
500 | 526 | | |
501 | 527 | | |
502 | 528 | | |
| |||
577 | 603 | | |
578 | 604 | | |
579 | 605 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 606 | + | |
589 | 607 | | |
590 | 608 | | |
591 | 609 | | |
| |||
594 | 612 | | |
595 | 613 | | |
596 | 614 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
| 615 | + | |
606 | 616 | | |
607 | 617 | | |
608 | 618 | | |
| |||
697 | 707 | | |
698 | 708 | | |
699 | 709 | | |
700 | | - | |
701 | 710 | | |
702 | 711 | | |
703 | 712 | | |
| |||
745 | 754 | | |
746 | 755 | | |
747 | 756 | | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
| 757 | + | |
| 758 | + | |
762 | 759 | | |
763 | 760 | | |
764 | 761 | | |
| 762 | + | |
765 | 763 | | |
766 | 764 | | |
767 | 765 | | |
| |||
776 | 774 | | |
777 | 775 | | |
778 | 776 | | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
| 777 | + | |
787 | 778 | | |
788 | 779 | | |
789 | 780 | | |
| |||
1531 | 1522 | | |
1532 | 1523 | | |
1533 | 1524 | | |
1534 | | - | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1535 | 1528 | | |
1536 | | - | |
| 1529 | + | |
| 1530 | + | |
1537 | 1531 | | |
1538 | 1532 | | |
1539 | 1533 | | |
| |||
1558 | 1552 | | |
1559 | 1553 | | |
1560 | 1554 | | |
1561 | | - | |
| 1555 | + | |
| 1556 | + | |
1562 | 1557 | | |
1563 | 1558 | | |
1564 | 1559 | | |
| |||
1592 | 1587 | | |
1593 | 1588 | | |
1594 | 1589 | | |
1595 | | - | |
| 1590 | + | |
1596 | 1591 | | |
1597 | 1592 | | |
1598 | 1593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1780 | 1780 | | |
1781 | 1781 | | |
1782 | 1782 | | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
0 commit comments