【发布时间】:2021-11-24 05:09:27
【问题描述】:
这个问题与Set size of matplotlib figure with 3d subplots有关。
这是一个示例代码。
fig = plt.figure()
fig.set_size_inches(10, 4)
ax = fig.gca(projection='3d')
上面的代码是我在 2019 年用于创建 3D 绘图的代码。
从 matplotlib 3.4 开始,不推荐使用关键字参数调用 gca()。
此外,3D 轴不再适合图形大小。
这是 matplotlib 3.4.3 的示例。
fig = plt.figure()
fig.set_size_inches(10, 4)
ax = plt.subplot(1, 1, 1)
fig = plt.figure()
fig.set_size_inches(10, 4)
ax = plt.subplot(1, 1, 1, projection='3d')
虽然老版本的matplotlib自动将3D轴适配到图中(对不起,我没有保存确切的版本号),但是matplotlib的当前-3.4.3版本不适配3D轴变成数字大小了。
我知道我可以按照set matplotlib 3d plot aspect ratio? 中的建议使用Axes3D.set_box_aspect()。但是,很难找到确切的纵横比值以使轴适合图形大小。 autoscale() 在这种情况下也无济于事。
总而言之,问题是:有什么方法可以(1)自动将 3D 轴拟合到图中(或者,改变 3D 轴的大小)(2)并防止边缘空间?
【问题讨论】:
标签: python matplotlib 3d