matplotlib 3D散点图点的颜色非常浅

发布于 2024-12-19 22:52:48 字数 473 浏览 2 评论 0原文

我使用下面的命令创建了 3D 散点图:

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

sizeseq = 2
colorseq = "k"

fig = plt.figure(1, (5,5), dpi=300)
ax = Axes3D(fig)
ax.view_init(20, -45)

x, y, z = [1,2,3,4,5,6,7,8,9,10], [1,2,3,4,5,6,7,8,9,10], [1,2,3,4,5,6,7,8,9,10]
ax.scatter(x, y, z, c=colorseq, s=sizeseq, lw=0, alpha=.8)

plt.show()

但即使我将 alpha 设置为 1,点的颜色看起来也很浅。它们看起来几乎就像在面具后面。它似乎还依赖于各个点的 3D 位置。有没有办法让所有的点看起来都很暗且不透明?

I used the command below to create a 3D scatter plot:

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

sizeseq = 2
colorseq = "k"

fig = plt.figure(1, (5,5), dpi=300)
ax = Axes3D(fig)
ax.view_init(20, -45)

x, y, z = [1,2,3,4,5,6,7,8,9,10], [1,2,3,4,5,6,7,8,9,10], [1,2,3,4,5,6,7,8,9,10]
ax.scatter(x, y, z, c=colorseq, s=sizeseq, lw=0, alpha=.8)

plt.show()

But the color of the dots look so light even when I set alpha to 1. They almost look like being behind a mask. It also seems dependent on the 3D position of the individual sots. Is there a way to make all of the dots look really dark and opaque?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛夏已如深秋| 2024-12-26 22:52:48

这看起来是使用奇特的 3D 效果进行分散的,因此您可以区分前景中的点和背景中的点。您可能需要破解 mplot3d 才能让它停止这样做。

或者,您可以使用不显示此行为的plot3D。

ax.plot3D(x, y, z, 'k.', alpha=.8)

This appears to be scatter using a fancy 3d effect so you can distinguish between dots in the foreground and dots in the background. You might have to hack mplot3d to get it to stop doing that.

Alternatively, you may be able to use plot3D which doesn't show this behaviour.

ax.plot3D(x, y, z, 'k.', alpha=.8)
陈甜 2024-12-26 22:52:48

当 alpha=0.8 时,点看起来已经非常透明。不要使用阿尔法。
此外,您可以通过用比各自表面颜色更深的颜色绘制点的边缘线来使点看起来更暗。
使用 scatter 关键字参数 edgecolor/edgecolors 或在创建散点后使用 myscatterplot.set_edgecolors(color)< 进行设置(例如,将所有带有黑色边框的点加粗)< /代码>

With alpha=0.8 dots already look very transparent. Don't use alpha.
In addition you can give a darker look to your dots by drawing their edgelines in a darker color than their respective facecolor.
Use scatter keyword parameter edgecolor/edgecolors or set after scatter creation(for example to bold all the points with a black border) with myscatterplot.set_edgecolors(color)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文