Skip to content

Instantly share code, notes, and snippets.

@mkacky
Created September 28, 2013 08:57
Show Gist options
  • Save mkacky/6740092 to your computer and use it in GitHub Desktop.
Save mkacky/6740092 to your computer and use it in GitHub Desktop.
test of legend position
#! /usr/bin/python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-2*np.pi, 2*np.pi, 0.1)
plt.plot(x, np.sin(x), label='sin(x)')
plt.plot(x, np.cos(x), label='cos(x)')
plt.grid(True)
# 1.2.1系では有効
#lgnd = plt.legend(loc="upper center", bbox_to_anchor=(0.5,-0.05), ncol=2)
#plt.savefig("legend_pos.eps", bbox_extra_artists=(lgnd,), bbox_inches='tight')
# 0.99系での応急処置
plt.legend(loc="upper center",
bbox_to_anchor=(0.5,-0.05), # 描画領域の少し下にBboxを設定
ncol=2 # 2列
)
plt.gcf().subplots_adjust(bottom=0.13)
plt.savefig("legend_pos.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment