는 ax.legend(loc='best')
을 사용
import matplotlib.pyplot as plt
import numpy as np
pi = np.pi
sin = np.sin
t = np.linspace(0.0, 2 * pi, 50)
markers = ['+', '*', ',', ] + [r'$\lambda$']
phases = [0, 0.5]
fig, ax = plt.subplots(len(phases))
for axnum, phase in enumerate(phases):
for i, marker in enumerate(markers, 1):
ax[axnum].plot(t, i*sin(2*t + phase*pi), marker=marker,
label='$i,\phi = {i},{p}$'.format(i=i, p=phase))
ax[axnum].legend(loc='best', numpoints=1)
plt.show()
흥미롭게도, 전설의 위치가 고정되어 있지 않습니다. GUI를 사용하여 그래프를 이동하면 범례의 위치가 자동으로 재조정됩니다.
'loc = 0' ('최상 ') 설정이 작동하지 않습니까? – tacaswell