Q:

Matplotlib: Legend not displayed properly

I have datapoints of different classes which I want to visualize. Here is the image that I get: http://imgur.com/1x97h
There are 3000 datapoints of 10 classes, 300 each. They are concatenated in a single array d over whose chunks I iterate. The labels are given in 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()

Has anyone a clue why my legend is screwed up?

A:

It would help to have a self-contained example, possibly with made-up data, so people can run it right away. Here's a self-contained example modified from what you posted that works fine for me in ipython -pylab, with a recent svn revision of Matplotlib; I think some legend-related bugs have been fixed recently.
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()

And here's what I get:
example figure http://www.iki.fi/jks/tmp/legend.png
Assuming the bug is related to the auto-legend feature, you might be able to work around it by being explicit about what you want in the legend:
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()

