datta

データを扱うときの私的メモ

【Python】グラフのアスペクト比を黄金比にする方法

ax = plt.gca()
ratio = 0.618
xleft, xright = ax.get_xlim()
ybottom, ytop = ax.get_ylim()
ax.set_aspect(abs((xright-xleft)/(ybottom-ytop))*ratio)

【参考】
How to Change the Aspect Ratio of Image (or Axes) in Matplotlib? - jdhao's blog