0
이 옵션은 작동하지 않습니다 ...scatter()에 범례를 추가하는 방법은 무엇입니까?
import numpy as np
import matplotlib.pyplot as plt
arr = np.random.random((5,3))
ax = plt.axes()
ax.scatter(arr[:,0],arr[:,1],c=['k','r','g','r','b'])
plt.legend(loc='upper left')
plt.draw()
ax = plt.axes()
h = ax.scatter(arr[:,0],arr[:,1],c=['k','r','g','r','b'])
plt.legend(h, loc='upper left')
plt.draw()
내가 대신 사용 플롯을 조립하고 루프를 쓸 수
,
colors = ['k','r','g','r','b']
ax = plt.axes()
h = []
for i,c in enumerate(colors):
h.append(ax.plot(arr[i,0],arr[i,1],c+'o'))
plt.legend(colors) ## plt.legend(h,colors) does not work
plt.draw()
을 내가 legend
에 h
를 전달하면, 그것은
warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle),))
을 말한다
하지만 루프를 작성하지 않고 분산 형으로이 작업을 수행하려면 어떻게해야합니까?
감사합니다. 내 대안은 수동으로 범례를 작성하는 방법이었습니다. 이거 야. – hatmatrix