调整三维散点图的大小

时间:2016-04-27 08:12:06

标签: python matplotlib image-resizing spyder scatter3d

我设法使用Spyder(Python 3.5)绘制3D图形。但是,图表的大小太小。如何增加图表的大小以便将其保存为图像文件?

以下是用于绘制图表的代码:

<td><input type="text" name="employeeModel.addresses[0].street" /></td>
<td><input type="text" name="employeeModel.addresses[0].city"    /></td>
<td><input type="text" name="employeeModel.addresses[0].country"  /></td>

谢谢!

1 个答案:

答案 0 :(得分:1)

创建图形时可以使用命名参数figsize

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')

x =[0, 1, 2, 3, 4, 0]
y =[11, 1, 5, 2, 9, 0]
z =[1, 2, 3, 4, 5, 6]  # this array contained one value too many. (I padded the other two arrays)

ax.scatter(x, y, z, c='r', marker='o')

ax.set_xlabel('Days since last interaction')
ax.set_ylabel('Number of conversions')
ax.set_zlabel('Total number of interactions')

plt.show()