moved call to legend() before call to draw()