python matplotlib legend linestyle '---'
<p>I need a way to make matplotlib linestyle '---'. 3's of '-'.</p>

<pre><code>character description
'-'       solid line style
'--'      dashed line style
'-.'      dash-dot line style
':'       dotted line style
etc.
</code></pre>

<p>I can see '-' and '--' in the list, but on the right up side, my legend comes up like " -- red dotted line" (If I write linestyle = '--'). I want '--- red dotted line' on my legend box</p>

<p>Is there any way I can make the legend show three dashes?
Here's what I'm doing.</p>

<pre><code>import matplotlib.pyplot as mpt

def main():
    mpt.title("hi")
    mpt.xlabel("x axis")
    mpt.ylim([0,50])
    mpt.xlim([0,10])
    mpt.ylabel("y axis")
    mpt.plot([1,2,3,4],[2,3,4,5],'r', linestyle = '???????')
    mpt.legend(["red dotted line"])
    mpt.show()

main()
</code></pre>

<p>Use <code>mpt.legend(handlelength=3)</code> and <code>linestyle='--'</code></p>

<pre><code>mpt.plot([1,2,3,4],[2,3,4,5],'r', linestyle='--')
mpt.legend(["red dotted line"], handlelength=3)
</code></pre>

python matplotlib