0
Q:

python add vertical line in plot

xposition = [0.3, 0.4, 0.45]
for xc in xposition:
    plt.axvline(x=xc, color='k', linestyle='--')
1
# 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
1
 pythonCopymatplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs)
0

New to Communities?

Join the community