Exemples de comment tracer une ligne pointillée avec matplotlib:
Table des matières
Tracer une ligne pointillée
Avec matplotlib il est possible de tracer des lignes en pointillée en ajoutant l'argument '--' ou ':' ou '-:', exemple:
import matplotlib.pyplot as pltx = [1,10]y = [3,6]plt.plot(x,y,'--')plt.savefig('DashedLine_01.png')plt.show()

import matplotlib.pyplot as pltx = [1,10]y = [3,6]plt.plot(x,y,':')plt.savefig('DashedLine_02.png')plt.show()

import matplotlib.pyplot as pltx = [1,10]y = [3,6]plt.plot(x,y,'-.')plt.savefig('DashedLine_03.png')plt.show()

Personnaliser la ligne pointillée
Il est aussi possible de créer sa propre ligne pointillée avec une mise en forme quelconque voir:
import matplotlib.pyplot as pltx = [1,10]y = [3,6]dashes = [5,2,10,5] # 5 points on, 2 off, 3 on, 1 offl, = plt.plot(x,y, '--')l.set_dashes(dashes)plt.title('How to plot a dashed line in matplotlib ?', fontsize=7)plt.savefig("dashed_line.png", bbox_inches='tight')plt.show()

Références
| Liens | Site |
|---|---|
| plot | matplotlib doc |
| pylab_examples example code: dash_control.py | matplotlib doc |
| python matplotlib dash-dot-dot - how to? | stackoverflow |
| A simple plot with a custom dashed line | matplotlib doc |
