Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f772eeb

Browse files
nhansendevscottshambaugh
authored andcommitted
Improvements for depth-shading
Added kwargs for depth-shading Create depthshading_improvement.rst Update art3d.py formatting Update axes3d.py formatting Update depthshading_improvement.rst formatting
1 parent d0c8011 commit f772eeb

File tree

3 files changed

+251
-59
lines changed

3 files changed

+251
-59
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Depth-shading fix and more depth-shading options
2+
--------------------------------------------------------------
3+
4+
New options have been added which allow users to modify the behavior of
5+
depth-shading while addressing a visual bug.
6+
7+
Previously, a slightly buggy method of estimating the "depth" of plotted
8+
items could lead to sudden and unexpected changes in transparency as the
9+
plot orientation changed.
10+
11+
Now, the behavior has been made smooth and predictable, and the user is
12+
provided with three new options: whether to invert the shading, setting the
13+
lowest acceptable alpha value (highest transparency), and whether to use
14+
the old algorithm.
15+
16+
The default behavior visually matches the old algorithm: items that appear to be
17+
"deeper" into the screen will become increasingly transparent (up to the now
18+
user-defined limit). If the inversion option is used then items will start
19+
at maximum transparency and become gradually opaque with increasing depth.
20+
21+
Note 1: depth-shading applies to Patch3DCollections and Path3DCollections,
22+
including scatter plots.
23+
24+
Note 2: "depthshade=True" must still be used to enable depth-shading
25+
26+
A simple example:
27+
28+
.. plot::
29+
import matplotlib.pyplot as plt
30+
31+
fig = plt.figure()
32+
ax = fig.add_subplot(projection="3d")
33+
34+
X = [i for i in range(10)]
35+
Y = [i for i in range(10)]
36+
Z = [i for i in range(10)]
37+
S = [(i + 1) * 400 for i in range(10)]
38+
39+
ax.scatter(
40+
xs=X,
41+
ys=Y,
42+
zs=Z,
43+
s=S,
44+
depthshade=True,
45+
depthshade_minalpha=0.1,
46+
depthshade_inverted=True,
47+
depthshade_legacy=True,
48+
)
49+
50+
plt.show()

0 commit comments

Comments
 (0)