I have difficulties to understand the legend handling. The more, the basic example from the official matplotlib legend guide
import matplotlib.pyplot as plt
I was having the same issue as Jan, running Matplotlib 1.3.1 on Ubuntu 14.04. I tried the answer posted by Kobi K. His code did not raise any errors. However, the legend did not render correctly: I upgraded to Matplotlib 1.5.1, and can now render the legend correctly using the code posted by Jan, which includes the 'handles' keyword (i.e. the code that appears in the Matplotlib legend guide):