@@ -633,9 +633,7 @@ def __init__(
633
633
zs = 0 ,
634
634
zdir = "z" ,
635
635
depthshade = True ,
636
- depthshade_inverted = False ,
637
636
depthshade_minalpha = 0.3 ,
638
- depthshade_legacy = False ,
639
637
axlim_clip = False ,
640
638
** kwargs
641
639
):
@@ -654,40 +652,24 @@ def __init__(
654
652
give the appearance of depth (default is *True*).
655
653
This is typically desired in scatter plots.
656
654
657
- *depthshade_inverted* sets whether to reverse the order of
658
- depth-shading transparency.
659
-
660
655
*depthshade_minalpha* sets the minimum alpha value applied by
661
656
depth-shading.
662
-
663
- *depthshade_legacy* sets whether to use the legacy algorithm
664
- for depth-shading.
665
657
"""
666
658
self ._depthshade = depthshade
667
- self ._depthshade_inverted = depthshade_inverted
668
659
self ._depthshade_minalpha = depthshade_minalpha
669
- self ._depthshade_legacy = depthshade_legacy
670
660
super ().__init__ (* args , ** kwargs )
671
661
self .set_3d_properties (zs , zdir , axlim_clip )
672
662
673
663
def get_depthshade (self ):
674
664
return self ._depthshade
675
665
676
- def get_depthshade_inverted (self ):
677
- return self ._depthshade_inverted
678
-
679
666
def get_depthshade_minalpha (self ):
680
667
return self ._depthshade_minalpha
681
668
682
- def get_depthshade_legacy (self ):
683
- return self ._depthshade_legacy
684
-
685
669
def set_depthshade (
686
670
self ,
687
671
depthshade ,
688
- depthshade_inverted = False ,
689
672
depthshade_minalpha = 0.3 ,
690
- depthshade_legacy = False ,
691
673
):
692
674
"""
693
675
Set whether depth shading is performed on collection members.
@@ -697,17 +679,11 @@ def set_depthshade(
697
679
depthshade : bool
698
680
Whether to shade the patches in order to give the appearance of
699
681
depth.
700
- depthshade_inverted : bool
701
- Whether to reverse order of depth-shading transparency.
702
682
depthshade_minalpha : float
703
683
Sets the minimum alpha value used by depth-shading.
704
- depthshade_legacy : bool
705
- Whtether to use the legacy algorithm for depth-shading.
706
684
"""
707
685
self ._depthshade = depthshade
708
- self ._depthshade_inverted = depthshade_inverted
709
686
self ._depthshade_minalpha = depthshade_minalpha
710
- self ._depthshade_legacy = depthshade_legacy
711
687
self .stale = True
712
688
713
689
def set_sort_zpos (self , val ):
@@ -767,9 +743,7 @@ def _maybe_depth_shade_and_sort_colors(self, color_array):
767
743
_zalpha (
768
744
color_array ,
769
745
self ._vzs ,
770
- inverted = self ._depthshade_inverted ,
771
746
min_alpha = self ._depthshade_minalpha ,
772
- legacy = self ._depthshade_legacy ,
773
747
)
774
748
if self ._vzs is not None and self ._depthshade
775
749
else color_array
@@ -813,9 +787,7 @@ def __init__(
813
787
zs = 0 ,
814
788
zdir = "z" ,
815
789
depthshade = True ,
816
- depthshade_inverted = False ,
817
790
depthshade_minalpha = 0.3 ,
818
- depthshade_legacy = False ,
819
791
axlim_clip = False ,
820
792
** kwargs
821
793
):
@@ -834,19 +806,11 @@ def __init__(
834
806
give the appearance of depth (default is *True*).
835
807
This is typically desired in scatter plots.
836
808
837
- *depthshade_inverted* sets whether to reverse the order of
838
- depth-shading transparency.
839
-
840
809
*depthshade_minalpha* sets the minimum alpha value applied by
841
810
depth-shading.
842
-
843
- *depthshade_legacy* sets whether to use the legacy algorithm
844
- for depth-shading.
845
811
"""
846
812
self ._depthshade = depthshade
847
- self ._depthshade_inverted = depthshade_inverted
848
813
self ._depthshade_minalpha = depthshade_minalpha
849
- self ._depthshade_legacy = depthshade_legacy
850
814
self ._in_draw = False
851
815
super ().__init__ (* args , ** kwargs )
852
816
self .set_3d_properties (zs , zdir , axlim_clip )
@@ -925,21 +889,13 @@ def set_linewidth(self, lw):
925
889
def get_depthshade (self ):
926
890
return self ._depthshade
927
891
928
- def get_depthshade_inverted (self ):
929
- return self ._depthshade_inverted
930
-
931
892
def get_depthshade_minalpha (self ):
932
893
return self ._depthshade_minalpha
933
894
934
- def get_depthshade_legacy (self ):
935
- return self ._depthshade_legacy
936
-
937
895
def set_depthshade (
938
896
self ,
939
897
depthshade ,
940
- depthshade_inverted = False ,
941
898
depthshade_minalpha = 0.3 ,
942
- depthshade_legacy = False ,
943
899
):
944
900
"""
945
901
Set whether depth shading is performed on collection members.
@@ -949,17 +905,11 @@ def set_depthshade(
949
905
depthshade : bool
950
906
Whether to shade the patches in order to give the appearance of
951
907
depth.
952
- depthshade_inverted : bool
953
- Whether to reverse order of depth-shading transparency.
954
908
depthshade_minalpha : float
955
909
Sets the minimum alpha value used by depth-shading.
956
- depthshade_legacy : bool
957
- Whtether to use the legacy algorithm for depth-shading.
958
910
"""
959
911
self ._depthshade = depthshade
960
- self ._depthshade_inverted = depthshade_inverted
961
912
self ._depthshade_minalpha = depthshade_minalpha
962
- self ._depthshade_legacy = depthshade_legacy
963
913
self .stale = True
964
914
965
915
def do_3d_projection (self ):
@@ -1021,9 +971,7 @@ def _maybe_depth_shade_and_sort_colors(self, color_array):
1021
971
color_array = _zalpha (
1022
972
color_array ,
1023
973
self ._vzs ,
1024
- inverted = self ._depthshade_inverted ,
1025
974
min_alpha = self ._depthshade_minalpha ,
1026
- legacy = self ._depthshade_legacy ,
1027
975
_data_scale = self ._data_scale ,
1028
976
)
1029
977
@@ -1051,9 +999,7 @@ def patch_collection_2d_to_3d(
1051
999
zs = 0 ,
1052
1000
zdir = "z" ,
1053
1001
depthshade = True ,
1054
- depthshade_inverted = False ,
1055
1002
depthshade_minalpha = 0.3 ,
1056
- depthshade_legacy = False ,
1057
1003
axlim_clip = False ,
1058
1004
):
1059
1005
"""
@@ -1073,12 +1019,8 @@ def patch_collection_2d_to_3d(
1073
1019
See `.get_dir_vector` for a description of the values.
1074
1020
depthshade
1075
1021
Whether to shade the patches to give a sense of depth. Default: *True*.
1076
- depthshade_invert
1077
- Whether to reverse order of depth-shading transparency. Default: *False*.
1078
1022
depthshade_minalpha
1079
1023
Sets the minimum alpha value used by depth-shading. Default: 0.3.
1080
- depthshade_legacy
1081
- Whether to use the legacy algorithm for depth-shading. Default: *False*.
1082
1024
axlim_clip : bool, default: False
1083
1025
Whether to hide patches with a vertex outside the axes view limits.
1084
1026
@@ -1089,9 +1031,7 @@ def patch_collection_2d_to_3d(
1089
1031
elif isinstance (col , PatchCollection ):
1090
1032
col .__class__ = Patch3DCollection
1091
1033
col ._depthshade = depthshade
1092
- col ._depthshade_inverted = depthshade_inverted
1093
1034
col ._depthshade_minalpha = depthshade_minalpha
1094
- col ._depthshade_legacy = depthshade_legacy
1095
1035
col ._in_draw = False
1096
1036
col .set_3d_properties (zs , zdir , axlim_clip )
1097
1037
@@ -1435,9 +1375,7 @@ def rotate_axes(xs, ys, zs, zdir):
1435
1375
def _zalpha (
1436
1376
colors ,
1437
1377
zs ,
1438
- inverted = False ,
1439
1378
min_alpha = 0.3 ,
1440
- legacy = False ,
1441
1379
_data_scale = None ,
1442
1380
):
1443
1381
"""Modify the alphas of the color list according to depth."""
@@ -1448,49 +1386,17 @@ def _zalpha(
1448
1386
# Alpha values beyond the range 0-1 inclusive make no sense, so clip them
1449
1387
min_alpha = np .clip (min_alpha , 0 , 1 )
1450
1388
1451
- if _data_scale is None or legacy :
1452
- # Revert to "legacy mode" if the new method of calculating
1453
- # _data_scale fails, or if the user asks for it
1454
-
1455
- # This only works well if the points for *zs* are well-spaced in
1456
- # all three dimensions. Otherwise, at certain orientations the
1457
- # min and max zs are very close together.
1458
- # Should really normalize against the viewing depth.
1459
-
1460
- # Normalize the z-depths to the range 0 - 1
1461
- norm = Normalize (min (zs ), max (zs ))
1462
-
1463
- # Generate alpha multipliers using the normalized z-depths so that
1464
- # closer points are opaque and the furthest points are still visible,
1465
- # but transparent
1466
- if inverted :
1467
- sats = norm (zs ) * (1 - min_alpha ) + min_alpha
1468
- else :
1469
- sats = 1 - norm (zs ) * (1 - min_alpha )
1389
+ if _data_scale is None or _data_scale == 0 :
1390
+ # Don't scale the alpha values since we have no valid data scale for reference
1391
+ sats = np .ones_like (zs )
1470
1392
1471
1393
else :
1472
- # Improved normalization using a scale value derived from the XYZ
1473
- # limits of the plot
1474
-
1475
- if _data_scale == 0 :
1476
- # Don't scale the alpha values since we have no valid
1477
- # data scale for reference
1478
- sats = np .ones_like (zs )
1479
-
1480
- else :
1481
- if inverted :
1482
- # Deeper points have an increasingly solid appearance
1483
- sats = np .clip (1 - (max (zs ) - zs ) / _data_scale , min_alpha , 1 )
1484
- else :
1485
- # This is the mode that most closely matches the legacy behavior
1486
-
1487
- # Deeper points have an increasingly transparent appearance
1488
- sats = np .clip (1 - (zs - min (zs )) / _data_scale , min_alpha , 1 )
1394
+ # Deeper points have an increasingly transparent appearance
1395
+ sats = np .clip (1 - (zs - min (zs )) / _data_scale , min_alpha , 1 )
1489
1396
1490
1397
rgba = np .broadcast_to (mcolors .to_rgba_array (colors ), (len (zs ), 4 ))
1491
1398
1492
- # Change the alpha values of the colors using the generated alpha
1493
- # multipliers
1399
+ # Change the alpha values of the colors using the generated alpha multipliers
1494
1400
return np .column_stack ([rgba [:, :3 ], rgba [:, 3 ] * sats ])
1495
1401
1496
1402
0 commit comments