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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With