Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit227fc6d

Browse files
Make axes3d.depthshade and axes3d.depthshade_minalpha rcparams
1 parent3ca67bc commit227fc6d

File tree

6 files changed

+58
-26
lines changed

6 files changed

+58
-26
lines changed

‎doc/users/next_whats_new/depthshading_improvement.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
3D depth-shading fix
22
--------------------
33

4-
Previously, a slightly buggy method of estimating the "depth" ofplotted
5-
items could lead to sudden and unexpected changes in transparency as the
6-
plotorientation changed.
4+
Previously, a slightly buggy method of estimating thevisual"depth" of3D
5+
items could lead to sudden and unexpected changes in transparency as the plot
6+
orientation changed.
77

88
Now, the behavior has been made smooth and predictable. A new parameter
99
``depthshade_minalpha`` has also been added to allow users to set the minimum
10-
transparency level.
10+
transparency level. Depth-shading is an option for Patch3DCollections and
11+
Path3DCollections, including 3D scatter plots.
1112

12-
Depth-shading is an option for Patch3DCollections and Path3DCollections,
13-
including 3D scatter plots. Depth-shading is still off by default, and
14-
``depthshade=True`` must still be used to enable it.
13+
The default values for ``depthshade`` and ``depthshade_minalpha`` are now also
14+
controlled via rcParams, with values of ``True`` and ``0.3`` respectively.
1515

1616
A simple example:
1717

‎lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@
433433
#axes3d.yaxis.panecolor: (0.90, 0.90, 0.90, 0.5) # background pane on 3D axes
434434
#axes3d.zaxis.panecolor: (0.925, 0.925, 0.925, 0.5) # background pane on 3D axes
435435

436+
#axes3d.depthshade: False # depth shade for 3D scatter plots
437+
#axes3d.depthshade_minalpha: 0.3 # minimum alpha value for depth shading
438+
436439
#axes3d.mouserotationstyle: arcball # {azel, trackball, sphere, arcball}
437440
# See also https://matplotlib.org/stable/api/toolkits/mplot3d/view_angles.html#rotation-with-mouse
438441
#axes3d.trackballsize: 0.667 # trackball diameter, in units of the Axes bbox

‎lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ axes.spines.top : True
225225
polaraxes.grid : True # display grid on polar axes
226226
axes3d.grid : True # display grid on 3D axes
227227
axes3d.automargin : False # automatically add margin when manually setting 3D axis limits
228+
axes3d.depthshade : False # depth shade for 3D scatter plots
229+
axes3d.depthshade_minalpha : 0.3 # minimum alpha value for depth shading
228230

229231
date.autoformatter.year : %Y
230232
date.autoformatter.month : %b %Y

‎lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,9 @@ def _convert_validator_spec(key, conv):
11191119
"axes3d.yaxis.panecolor":validate_color,# 3d background pane
11201120
"axes3d.zaxis.panecolor":validate_color,# 3d background pane
11211121

1122+
"axes3d.depthshade":validate_bool,# depth shade for 3D scatter plots
1123+
"axes3d.depthshade_minalpha":validate_float,# minimum alpha value for depth shading
1124+
11221125
"axes3d.mouserotationstyle": ["azel","trackball","sphere","arcball"],
11231126
"axes3d.trackballsize":validate_float,
11241127
"axes3d.trackballborder":validate_float,

‎lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
frommatplotlibimport (
1717
_api,artist,cbook,colorsasmcolors,lines,textasmtext,
18-
pathasmpath)
18+
pathasmpath,rcParams)
1919
frommatplotlib.collectionsimport (
2020
Collection,LineCollection,PolyCollection,PatchCollection,PathCollection)
2121
frommatplotlib.patchesimportPatch
@@ -631,8 +631,8 @@ def __init__(
631631
*args,
632632
zs=0,
633633
zdir="z",
634-
depthshade=True,
635-
depthshade_minalpha=0.3,
634+
depthshade=None,
635+
depthshade_minalpha=None,
636636
axlim_clip=False,
637637
**kwargs
638638
):
@@ -654,6 +654,10 @@ def __init__(
654654
*depthshade_minalpha* sets the minimum alpha value applied by
655655
depth-shading.
656656
"""
657+
ifdepthshadeisNone:
658+
depthshade=rcParams['axes3d.depthshade']
659+
ifdepthshade_minalphaisNone:
660+
depthshade_minalpha=rcParams['axes3d.depthshade_minalpha']
657661
self._depthshade=depthshade
658662
self._depthshade_minalpha=depthshade_minalpha
659663
super().__init__(*args,**kwargs)
@@ -665,7 +669,7 @@ def get_depthshade(self):
665669
defset_depthshade(
666670
self,
667671
depthshade,
668-
depthshade_minalpha=0.3,
672+
depthshade_minalpha=None,
669673
):
670674
"""
671675
Set whether depth shading is performed on collection members.
@@ -675,9 +679,12 @@ def set_depthshade(
675679
depthshade : bool
676680
Whether to shade the patches in order to give the appearance of
677681
depth.
678-
depthshade_minalpha : float
682+
depthshade_minalpha : float, default: None
679683
Sets the minimum alpha value used by depth-shading.
684+
If None, use the value from rcParams['axes3d.depthshade_minalpha'].
680685
"""
686+
ifdepthshade_minalphaisNone:
687+
depthshade_minalpha=rcParams['axes3d.depthshade_minalpha']
681688
self._depthshade=depthshade
682689
self._depthshade_minalpha=depthshade_minalpha
683690
self.stale=True
@@ -782,8 +789,8 @@ def __init__(
782789
*args,
783790
zs=0,
784791
zdir="z",
785-
depthshade=True,
786-
depthshade_minalpha=0.3,
792+
depthshade=None,
793+
depthshade_minalpha=None,
787794
axlim_clip=False,
788795
**kwargs
789796
):
@@ -805,6 +812,10 @@ def __init__(
805812
*depthshade_minalpha* sets the minimum alpha value applied by
806813
depth-shading.
807814
"""
815+
ifdepthshadeisNone:
816+
depthshade=rcParams['axes3d.depthshade']
817+
ifdepthshade_minalphaisNone:
818+
depthshade_minalpha=rcParams['axes3d.depthshade_minalpha']
808819
self._depthshade=depthshade
809820
self._depthshade_minalpha=depthshade_minalpha
810821
self._in_draw=False
@@ -888,7 +899,7 @@ def get_depthshade(self):
888899
defset_depthshade(
889900
self,
890901
depthshade,
891-
depthshade_minalpha=0.3,
902+
depthshade_minalpha=None,
892903
):
893904
"""
894905
Set whether depth shading is performed on collection members.
@@ -901,6 +912,8 @@ def set_depthshade(
901912
depthshade_minalpha : float
902913
Sets the minimum alpha value used by depth-shading.
903914
"""
915+
ifdepthshade_minalphaisNone:
916+
depthshade_minalpha=rcParams['axes3d.depthshade_minalpha']
904917
self._depthshade=depthshade
905918
self._depthshade_minalpha=depthshade_minalpha
906919
self.stale=True
@@ -991,10 +1004,10 @@ def patch_collection_2d_to_3d(
9911004
col,
9921005
zs=0,
9931006
zdir="z",
994-
depthshade=True,
1007+
depthshade=None,
9951008
axlim_clip=False,
9961009
*args,
997-
depthshade_minalpha=0.3
1010+
depthshade_minalpha=None,
9981011
):
9991012
"""
10001013
Convert a `.PatchCollection` into a `.Patch3DCollection` object
@@ -1011,10 +1024,12 @@ def patch_collection_2d_to_3d(
10111024
zdir : {'x', 'y', 'z'}
10121025
The axis in which to place the patches. Default: "z".
10131026
See `.get_dir_vector` for a description of the values.
1014-
depthshade
1015-
Whether to shade the patches to give a sense of depth. Default: *True*.
1016-
depthshade_minalpha
1017-
Sets the minimum alpha value used by depth-shading. Default: 0.3.
1027+
depthshade : bool, default: None
1028+
Whether to shade the patches to give a sense of depth.
1029+
If None, use the value from rcParams['axes3d.depthshade'].
1030+
depthshade_minalpha : float, default: None
1031+
Sets the minimum alpha value used by depth-shading.
1032+
If None, use the value from rcParams['axes3d.depthshade_minalpha'].
10181033
axlim_clip : bool, default: False
10191034
Whether to hide patches with a vertex outside the axes view limits.
10201035
"""
@@ -1023,6 +1038,10 @@ def patch_collection_2d_to_3d(
10231038
col._offset_zordered=None
10241039
elifisinstance(col,PatchCollection):
10251040
col.__class__=Patch3DCollection
1041+
ifdepthshadeisNone:
1042+
depthshade=rcParams['axes3d.depthshade']
1043+
ifdepthshade_minalphaisNone:
1044+
depthshade_minalpha=rcParams['axes3d.depthshade_minalpha']
10261045
col._depthshade=depthshade
10271046
col._depthshade_minalpha=depthshade_minalpha
10281047
col._in_draw=False

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,9 +2903,9 @@ def add_collection3d(self, col, zs=0, zdir='z', autolim=True, *,
29032903
@_preprocess_data(replace_names=["xs","ys","zs","s",
29042904
"edgecolors","c","facecolor",
29052905
"facecolors","color"])
2906-
defscatter(self,xs,ys,zs=0,zdir='z',s=20,c=None,depthshade=True,
2906+
defscatter(self,xs,ys,zs=0,zdir='z',s=20,c=None,depthshade=None,
29072907
*args,
2908-
depthshade_minalpha=0.3,
2908+
depthshade_minalpha=None,
29092909
axlim_clip=False,
29102910
**kwargs):
29112911
"""
@@ -2939,14 +2939,15 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
29392939
- A 2D array in which the rows are RGB or RGBA.
29402940
29412941
For more details see the *c* argument of `~.axes.Axes.scatter`.
2942-
depthshade : bool, default:True
2942+
depthshade : bool, default:None
29432943
Whether to shade the scatter markers to give the appearance of
29442944
depth. Each call to ``scatter()`` will perform its depthshading
29452945
independently.
2946+
If None, use the value from rcParams['axes3d.depthshade'].
29462947
2947-
depthshade_minalpha : float, default:0.3
2948+
depthshade_minalpha : float, default:None
29482949
The lowest alpha value applied by depth-shading.
2949-
2950+
If None, use the value from rcParams['axes3d.depthshade_minalpha'].
29502951
axlim_clip : bool, default: False
29512952
Whether to hide the scatter points outside the axes view limits.
29522953
@@ -2974,6 +2975,10 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
29742975
)
29752976
ifkwargs.get("color")isnotNone:
29762977
kwargs['color']=color
2978+
ifdepthshadeisNone:
2979+
depthshade=mpl.rcParams['axes3d.depthshade']
2980+
ifdepthshade_minalphaisNone:
2981+
depthshade_minalpha=mpl.rcParams['axes3d.depthshade_minalpha']
29772982

29782983
# For xs and ys, 2D scatter() will do the copying.
29792984
ifnp.may_share_memory(zs_orig,zs):# Avoid unnecessary copies.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp