Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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. This makes it very hard to visually compare the colors of the individual points.

Is there some way to turn this off?

like image 739
Benno Avatar asked Feb 03 '13 17:02

Benno


People also ask

How do I change the transparency in Matplotlib?

Matplotlib allows you to regulate the transparency of a graph plot using the alpha attribute. By default, alpha=1. If you would like to form the graph plot more transparent, then you'll make alpha but 1, such as 0.5 or 0.25.

How do you make a 3D plot transparent in Python?

Matplotlib allows you to adjust the transparency of a graph plot using the alpha attribute. If you want to make the graph plot more transparent, then you can make alpha less than 1, such as 0.5 or 0.25. If you want to make the graph plot less transparent, then you can make alpha greater than 1.

How do you add a transparency to a scatter plot in Python?

Adjust the Transparency of Scatter PointsUtilize the alpha argument in our scatter method and pass in a numeric value between 0 and 1. A value of 0 will make the plots fully transparent and unable to view on a white background. A value of 1 is the default with non-transparent points.

Which parameter should you use to change a plots transparency?

In order to change the transparency of a graph plot in matplotlib we will use the matplotlib. pyplot. plot() function. The plot() function in pyplot module of matplotlib library is used to make 2D illustrations.


1 Answers

You need to add depthshade=False as an argument in the scatter function.

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

Matplotlib 3D tutorial

like image 184
Andrea Avatar answered Oct 07 '22 23:10

Andrea