2016-01-30 9 views
10

In Python mit matplotlib, ist es eine Möglichkeit, den Abstand der Striche für verschiedene Linienstile zum Beispiel zu ändern, mit dem folgenden Befehl:ändert Abstand von Strichen in gestrichelte Linie in matplotlib

+0

Würde nicht mit benutzerdefinierten Linienstile tun? Siehe [hier] (http://stackoverflow.com/questions/14710221/python-matplotlib-dash-dot-dot-how-to) –

Antwort

17

können Sie Geben Sie die Striche length/space direkt unter Verwendung des dashes=(length, interval space)-Arguments innerhalb des Plot-Befehls an.

import matplotlib.pyplot as plt 

fig,ax = plt.subplots() 
ax.plot([0, 1], [0, 1], linestyle='--', dashes=(5, 1)) #length of 5, space of 1 
ax.plot([0, 1], [0, 2], linestyle='--', dashes=(5, 5)) #length of 5, space of 5 
ax.plot([0, 1], [0, 3], linestyle='--', dashes=(5, 10)) #length of 5, space of 10 
ax.plot([0, 1], [0, 4], linestyle='--', dashes=(5, 20)) #length of 5, space of 20 

lines