Matplotlib中如何使用Axes3D进行缩放? 要使用Axes3D进行缩放,可以按照以下步骤进行- 设置图形大小并调整子图之间和周围的填充。 创建新图形或使用 figure() 方法激活现有图形。 使用 Axes3D(fig) 方法获取3D轴对象。 使用 scatter() 方法绘制 x , y 和 z 数据点。 使用 show() 方法显示图形。 示例 from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt plt.rcParams ["figure.figsize"] = [7.50,3.50] plt.rcParams ["figure.autolayout"] = True fig = plt.figure() ax = Axes3D(fig) x = [2, 4, 6, 3, 1] y = [1, 6, 8, 1, 3] z = [3, 4, 10, 3, 1] ax.scatter3D(x, y, z, c=z, alpha=1, marker='d', s=150) plt.show() PythonCopy 输出