Changed legend function so that the line shows correctly