[英]How to turn off transparency in Matplotlib's 3D Scatter plot?
I'm using Matplotlib's Axes3D to create a scatter plot with custom colors like this: 我正在使用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)
This works fine, but matplotlib automatically adds some shading to make more distant points appear more transparent/in a lighter color than closer points. 这可以正常工作,但是matplotlib自动添加一些阴影,以使较远的点比较近的点更透明/颜色更浅。 This makes it very hard to visually compare the colors of the individual points.
这使得很难直观地比较各个点的颜色。
Is there some way to turn this off? 有什么办法可以关闭此功能吗?
只需在散点函数中添加alpha = 1
作为参数。
ax.scatter(xval, yval, zval, c=cval, alpha = 1, cmap=plt.cm.gray)
You need to add depthshade=False
as an argument in the scatter function. 您需要在分散函数中添加
depthshade=False
作为参数。
ax.scatter(xval, yval, zval, c=cval, cmap=plt.cm.gray, depthshade=False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.