Axes3D.scatter()
时间: 2024-05-16 12:11:54 浏览: 8
Axes3D.scatter() is a method in the Matplotlib library that creates a 3D scatter plot. It takes in three arrays of data representing the X, Y, and Z coordinates of the points to be plotted. Additionally, it allows for customization of the marker style, color, and size.
Here is an example of how to use Axes3D.scatter() to create a scatter plot in 3D:
```python
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
# Generate some random data
x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)
# Create a 3D scatter plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z, marker='o', color='blue')
# Set axis labels and title
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('3D Scatter Plot')
# Display the plot
plt.show()
```
This code generates 100 random points in 3D space and plots them as blue circles. The resulting plot can be rotated and viewed from different angles using the mouse.