如何使 3D python 散点图中的数据点看起来像 "discs" 而不是 "spheres"

How to make data points in a 3D python scatter plot look like "discs" instead of "spheres"

在标准 3D python 图中,每个数据点默认表示为 3D 球体。对于我正在绘制的数据,z 轴非常敏感,而 x 和 y 轴非常通用,所以有没有办法让散点图上的每个点像往常一样散布在 x 和 y 方向上例如,s=500,但根本不会沿 z 轴展开?理想情况下,这看起来像一组堆叠的圆盘,而不是重叠的球体。

有什么想法吗?我对 python 比较陌生,我不知道是否有办法用散点图制作这样的自定义数据点。

您可能会寻找名为 "jittering" 的内容。看一眼 Matplotlib: avoiding overlapping datapoints in a "scatter/dot/beeswarm" plot 它通过向数据添加随机噪声来工作。

另一种方法可能是减少 z 轴上数据的方差(例如应用对数函数)或调整比例。您可以使用 ax.set_zscale("log") 来做到这一点。此处记录 http://matplotlib.org/mpl_toolkits/mplot3d/api.html#mpl_toolkits.mplot3d.axes3d.Axes3D.set_zscale

我实际上能够使用 matplotlib.patches 库来做到这一点,为每个数据点创建一个补丁,然后在 mpl_toolkits.mplot3d.art3d 的帮助下将其制作成我想要的任何形状.