py vertical line code example

Example 1: python add vertical line in plot

# Basic syntax:
plt.axvline(x_coordinate)

# Example usage:
import matplotlib.pyplot as plt
plt.figure(figsize=(5, 5))
plt.axvline(x=10, ymin=0.10, ymax=0.70, color='b', ls='--', lw=1.5, label='axvline - % of full height')
plt.legend(bbox_to_anchor=(1.0, 1), loc='best')
plt.show()

# Where:
#	- x is the x axis coordinate for the vertical line
#	- ymin is the minimum y-value to show
#	- ymax is the maximum y-value to show
#	- ls is the line style (see also '-', '-.', and ':')
#	- lw is the line width

Example 2: vertical line in matplotlib

xposition = [0.3, 0.4, 0.45]
for xc in xposition:
    plt.axvline(x=xc, color='k', linestyle='--')