각 커브에 레이블이있는 6 개의 커브로 그래프를 플로팅합니다. 범례는 그래프 아래에 배치되지만 그림보다 넓습니다. 코드 및 스크린 샷을 참조하십시오.Matplotlib 범례가 너무 넓음
#!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
fig = plt.figure()
ax = plt.subplot(111)
for i in xrange(6):
ax.plot(x, i * x, label='long_long_name = %ix$' % i)
#ax.legend()
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
fancybox=True, shadow=True, ncol=3)
fig.tight_layout(rect=[0, 0.1, 1, 0.95])
plt.show()
적절한 그래프 및 범례 크기/위치를 구성하는 방법은 무엇입니까? Legend Guide과 this post을 보았지만 범례를 더 좁게 만드는 방법을 알 수 없었습니다.
단지 지정하지 왜 '에는 NcoI = 2 '? – saintsfan342000
실제로 잘 작동했습니다. 감사합니다 –