Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw more type of lines in matplotlib

There are only 4 types of line style in matplotlib: ['--', '-.', '-', ':']. Can one make more than 4 different types of line style in matplotlib?

like image 660
Timothy Avatar asked Oct 26 '15 03:10

Timothy


People also ask

How do I make a dashed line in matplotlib?

x: X-axis points on the line. y: Y-axis points on the line. linestyle: Change the style of the line.


1 Answers

The latest matplotlib documentation (currently unreleased) includes many custom linestyle examples right now. Here's a screen shot:

enter image description here

For easier copy paste, here's part of the code used to make that plot:

linestyle_tuple = [
     ('loosely dotted',        (0, (1, 10))),
     ('dotted',                (0, (1, 1))),
     ('densely dotted',        (0, (1, 1))),

     ('loosely dashed',        (0, (5, 10))),
     ('dashed',                (0, (5, 5))),
     ('densely dashed',        (0, (5, 1))),

     ('loosely dashdotted',    (0, (3, 10, 1, 10))),
     ('dashdotted',            (0, (3, 5, 1, 5))),
     ('densely dashdotted',    (0, (3, 1, 1, 1))),

     ('dashdotdotted',         (0, (3, 5, 1, 5, 1, 5))),
     ('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))),
     ('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]
like image 90
James Wright Avatar answered Sep 29 '22 08:09

James Wright