- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Controlling the alpha value on a 3D scatter plot using Python and Matplotlib
To control the alpha value on a 3D scatter plot using Python and Matplotlib, we can set the facecolor and edgecolors value.
- Set the figure size and adjust the padding between and around the subplots.
- Create a new figure or activate an existing figure using figure() method.
- Add an '~.axes.Axes' to the figure as part of a subplot arrangement.
- Create x, y and z data points using numpy.
- Plot x, y and z points using scatter() method.
- Set the facecolors and edgecolors.
- To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(projection='3d') x = np.random.sample(20) y = np.random.sample(20) z = np.random.sample(20) s = ax.scatter(x, y, z, c="r") s._set_facecolors, s._set_edgecolors = s.set_facecolors, s.set_edgecolors plt.show()
Output
Advertisements