Python 使用三维子地块设置matplotlib地物的大小
我有一个图形,我想在其中绘制一个3d散点图和一个法线图,分为两个子图。 我使用这个代码Python 使用三维子地块设置matplotlib地物的大小,python,matplotlib,Python,Matplotlib,我有一个图形,我想在其中绘制一个3d散点图和一个法线图,分为两个子图。 我使用这个代码 fig = plt.figure(1) ax = fig.add_subplot(211, projection='3d') ax2 = fig.add_subplot(212) 然后我使用ax和ax2在正确的位置绘制数据。但是我得到的数字太小了,我怎样才能把它变大呢?在第一行中添加figsize=(w,h)没有任何效果,如果我将它添加到第二行或第三行,则会导致错误: AttributeError:“Axe
fig = plt.figure(1)
ax = fig.add_subplot(211, projection='3d')
ax2 = fig.add_subplot(212)
然后我使用ax和ax2在正确的位置绘制数据。但是我得到的数字太小了,我怎样才能把它变大呢?在第一行中添加figsize=(w,h)
没有任何效果,如果我将它添加到第二行或第三行,则会导致错误:
AttributeError:“Axes3DSubplot”对象没有属性“set\u figsize”
将figsize=(w,h)
添加到第一行就可以了。你说的“没有效果”是什么意思
例如:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig1=plt.figure(figsize=(8,5))
ax11=fig1.add_subplot(211,projection='3d')
ax12=fig1.add_subplot(212)
fig1.get_size_inches()
# array([ 8., 5.])
fig2=plt.figure(figsize=(4,4))
ax21=fig1.add_subplot(211,projection='3d')
ax22=fig1.add_subplot(212)
fig2.get_size_inches()
# array([ 4., 4.])
fig1.savefig('fig1.png',dpi=300)
fig2.savefig('fig2.png',dpi=300)
以300dpi的速度将数字保存为png后:
$ identify fig1.png
>>> fig1.png PNG 2400x1500 2400x1500+0+0 8-bit sRGB 118KB 0.000u 0:00.000
$ identify fig2.png
>>> fig2.png PNG 1200x1200 1200x1200+0+0 8-bit sRGB 86.9KB 0.000u 0:00.000
您使用的matplotlib版本是什么?在我的Conda环境中,我确实安装了3.0.0,而改变figsize似乎完全不会改变什么。在Jupyter绘制它