在Matplotlib中更改子图的大小

时间:2020-04-27 03:06:42

标签: python matplotlib

我正在尝试绘制房屋面积与房屋价格编号的2个相关曲线。房间数与房价的对比 但是,我得到的每个子图的大小都很小。如何调整两个子图的大小,使其足够大。

import matplotlib.pyplot as plt

#X is a Matrix of dimension (47,2), Y is column vector dim=(47,1)

plt.subplots_adjust(wspace=4);
plt.subplot(1,2,1); 
plt.scatter(X[:,0],y);
plt.subplot(1,2,2);
plt.scatter(X[:,1],y);
plt.show();

this

1 个答案:

答案 0 :(得分:0)

插入figsize应该可以。因此您的新代码可能类似于:

import matplotlib.pyplot as plt

plt.subplots(1,2,figsize=(15,15))#one example of sizing
plt.subplots_adjust(wspace=4);
plt.subplot(1,2,1); 
plt.scatter(X[:,0],y);
plt.subplot(1,2,2);
plt.scatter(X[:,1],y);
plt.show();

查看此信息:How do I change the figure size with subplots?