プロット図を縮小して空きを作る
fig.subplots_adjust(top=0.7) とし、図の上側に空きを作る。
#!/usr/bin/env python import random import matplotlib.pyplot as plt def plot(): xval = [random.normalvariate( 50,100) for i in range(10000)] yval = [random.normalvariate(-50,100) for i in range(10000)] fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.set_xlim([-400,400]) ax.set_ylim([-400,400]) ax.grid() ax.plot(xval,yval,linestyle="None",marker="+") fig.subplots_adjust(top=0.7) plt.savefig('test.png') if __name__=="__main__": plot()
subplots_adjust()の仕様:
subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
- 各値の意味(とデフォルト値):
- left = 0.125: 図の左端
- bottom = 0.1: 図の下端
- right = 0.9: 図の右端
- top = 0.9: 図の上端
- wspace = 0.2: subplot間の横幅の空き
- hspace = 0.2: subplot間の縦幅の空き
※デフォルト値は rc ファイルで設定可能。