문제

시각화하고 싶은 다른 클래스의 데이터 포인트가 있습니다. 내가 얻는 이미지는 다음과 같습니다. http://imgur.com/1x97h

각각 300 개의 클래스의 3000 개의 데이터 포인트가 각각 300 개가 있습니다. 그들은 단일 배열로 연결됩니다 d 나는 누구의 덩어리를 반복합니다. 라벨이 주어집니다 labels.

pylab.clf()
colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
for l, c  in zip(labels, colors):
  start, stop = i * 300, (i + 1) * 300
  pylab.plot(d[0, start:stop], d[1, start:stop], c, label=l)

pylab.legend(loc='lower left')
pylab.show()

내 전설이 왜 망가 졌는지 단서가 있습니까?

도움이 되었습니까?

해결책

자체 포함 된 예제, 아마도 메이크업 데이터를 사용하는 데 도움이되므로 사람들은 즉시 실행할 수 있습니다. 다음은 당신이 게시 한 내용에서 수정 된 독립적 인 예입니다. ipython -pylab, Matplotlib의 최근 SVN 개정과 함께; 최근에 전설 관련 버그가 최근에 고정되었다고 생각합니다.

colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
labels = 'one two three four five six seven eight nine ten'.split()
x = linspace(0, 2*pi, 3000)
d = (2+random((2,3000))) * c_[sin(x), cos(x)].T
for i, l, c  in zip(range(10), labels, colors):
    start, stop = i * 300, (i + 1) * 300
    plot(d[0, start:stop], d[1, start:stop], c, label=l)
legend(loc='lower left')
show()

그리고 여기에 내가 얻는 것이 있습니다.

그림 http://www.iki.fi/jks/tmp/legend.png

버그가 자동 수석 기능과 관련이 있다고 가정하면 전설에서 원하는 것에 대해 명시 적으로 일할 수 있습니다.

colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
labels = 'one two three four five six seven eight nine ten'.split()
x = linspace(0, 2*pi, 3000)
d = (2+random((2,3000))) * c_[sin(x), cos(x)].T
lg = []
for i, l, c  in zip(range(10), labels, colors):
    start, stop = i * 300, (i + 1) * 300
    handle = plot(d[0, start:stop], d[1, start:stop], c, label=l)
    lg.append(handle)
legend(lg, labels, loc='lower left')
show()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top