python - 如何关闭 Matplotlib 3D 散点图中的透明度?

标签 python matplotlib

我正在使用 Matplotlib 的 Axes3D 创建具有自定义颜色的散点图,如下所示:

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt

fig = plt.figure(1)
ax = Axes3D(fig)
ax.scatter(xval, yval, zval, c=cval, cmap=plt.cm.gray)

这很好用,但 matplotlib 会自动添加一些阴影,使更远的点比更近的点显得更透明/颜色更浅。这使得很难直观地比较各个点的颜色。

有什么方法可以关闭它吗?

最佳答案

您需要在散点函数中添加 depthshade=False 作为参数。

ax.scatter(xval, yval, zval, c=cval, cmap=plt.cm.gray, depthshade=False)

Matplotlib 3D tutorial

关于python - 如何关闭 Matplotlib 3D 散点图中的透明度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14674885/

相关文章:

python - 如何以及在哪里计算 python 中的派生实例变量

python - 如何将无维度添加回张量?

Python Matplotlib - 保存的图像在使用 for 循环时被覆盖

matplotlib:重绘前清除散点数据

python - python中的前导零

python - 如何在 python 3.7 中使用 AES-128-CTR 使用给定 key 和 iv 加密明文?

python - Pandas 创建新的数据框,从多个观察中选择最大值

python - 一个图中具有不同seaborn调色板的曲线族

python - 如何确保绘图的 x 轴和 y 轴大小相等?

python - matplotlib 中的子图给出 ValueError : not enough values to unpack