Python绘制多种颜色的三维散点图

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
plt.style.use('seaborn-darkgrid')

# Make data
np.random.seed(19680801)
n = 100
rng = np.random.default_rng()
xs = rng.uniform(23, 32, n)
ys = rng.uniform(0, 100, n)
zs = rng.uniform(-50, -25, n)

# Plot
fig, ax = plt.subplots(subplot_kw={
    
    "projection": "3d"})
ax.scatter(xs, ys, zs,color='red')

ax.set(xticklabels=[],
       yticklabels=[],
       zticklabels=[])

plt.show()

在这里插入图片描述

ax.scatter(xs, ys, zs,color='teal')

在这里插入图片描述

ax.scatter(xs, ys, zs,color='purple')

在这里插入图片描述

ax.scatter(xs, ys, zs,color='maroon')

在这里插入图片描述
参考文献:https://matplotlib.org/stable/plot_types/3D/scatter3d_simple.html

猜你喜欢

转载自blog.csdn.net/m0_38127487/article/details/132186140