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

Skip to content

[Bug]: 3D scatter plot flips alpha order depending on depth relative to camera #22861

Closed
@nhansendev

Description

@nhansendev

Bug summary

When plotting a 3D scatter plot with multiple alpha values the resulting alpha values that are plotted depend on the order of points relative to the camera. This behavior continues even if depthshade=False is used. The behavior stops if the points are plotted individually using a for loop.

Code for reproduction

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(projection="3d")

X = [i for i in range(10)]
Y = [i for i in range(10)]
Z = [i for i in range(10)]
S = [(i+1)*400 for i in range(10)]
A = [i/10 for i in range(10)]

ax.scatter(xs=X, ys=Y, zs=Z, s=S, alpha=A, depthshade=False)

plt.show()

Actual outcome

Ex: In the images below you can see the result of slightly rotating the same plot so that one end of the line of points is closer or further from the camera. This causes the list of alpha values to be applied in either the intended order, or the reverse of that order.

Screenshot from 2022-04-17 13-37-52
Screenshot from 2022-04-17 13-38-01

Expected outcome

Simply: the 3D scatter plot alpha values when depthshade=False is used should not depend on the depth from the camera.

Additional information

I've seen closed issues where something very similar was fixed for old versions of matplotlib (python 2 era), so it looks like this bug has resurfaced?

Operating system

Ubuntu

Matplotlib Version

matplotlib 3.5.1

Matplotlib Backend

No response

Python version

Python 3.9.5

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions