Exemples de comment tracer une simple ligne verticale dans une figure matplotlib:
Table des matières
Tracer une ligne verticale
Pour tracer une simple ligne verticale dans une figure matplotlib on peut utiliser axvline, illustration

import matplotlib.pyplot as pltimport numpy as npx = np.linspace(0, 2*np.pi, 1000)y1 = np.sin(x)f = plt.figure()ax = f.add_subplot(111)plt.plot(x, y1)plt.axvline(x=np.pi)plt.title('How to plot a vertical line with matplotlib ?', fontsize=8)plt.xlim(0, 2.0*np.pi)plt.ylim(-1.5, 1.5)plt.savefig('matplotlib_vertical_line_01.png', bbox_inches='tight')plt.show()
Changer la couleur
plt.axvline(x=np.pi,color='gray')

Mettre la ligne en pointillée
plt.axvline(x=np.pi,color='gray',linestyle='--')

Références
| Liens | Site |
|---|---|
| Python matplotlib.pyplot.axvline() Examples | programcreek.com |
| How to draw vertical lines on a given plot in matplotlib? | stackoverflow |
