2017-01-08 9 views
3

Figureが複数のサブプロット(私の場合は5×2)を含む場合、サブプロットのサイズを設定する方法を知りました。どんなに大きくしても、サブプロットは常に小さく見えます。この図では、サブプロットのサイズを直接制御したいと考えています。コードの簡略版は以下に貼り付けられています。あなたのプロットのためのページ全体を使用するようにmatplotlibのサブプロットのサイズを設定します

fig = plt.figure(figsize=(8, 20)) 

:に

fig = plt.figure(figsize=(20, 8)) 

import numpy as np 
import matplotlib.pyplot as plt 

x = np.random.randn(20) 
y = np.random.randn(20) 

fig = plt.figure(figsize=(20, 8)) 

for i in range(0,10): 
    ax = fig.add_subplot(5, 2, i+1) 
    plt.plot(x, y, 'o') 
    ax.xaxis.set_visible(False) 
    ax.yaxis.set_visible(False) 
    # x and y axis should be equal length 
    x0,x1 = ax.get_xlim() 
    y0,y1 = ax.get_ylim() 
    ax.set_aspect(abs(x1-x0)/abs(y1-y0)) 

plt.show() 
fig.savefig('plot.pdf', bbox_inches='tight') 
+1

:に

enter image description here

。アスペクト比はほぼ正方形のサブプロットに設定されていますが、Figureはそうではありません。 – Serenity

答えて

10

ちょうどからFigureサイズの幅と高さを切り替えます。

これはからあなたのプロットを変更します:、すなわち `figsize =(20,20)`平方フィギュアのサイズを設定してみ

enter image description here

関連する問題