简体   繁体   English

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

[英]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? 有什么办法可以关闭此功能吗?

This is actually a feature of Matplotlib's 2d plot scatter plot as well, and here is a question with a potential solution to it. 这实际上是Matplotlib的2D情节散点图特征为好,这里是一个问题,一个可能的解决方案吧。

Scatter 's inputs are what actually needs to be configured. Scatter的输入实际上是需要配置的。

只需在散点函数中添加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)

Matplotlib 3D tutorial Matplotlib 3D教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM