Sometimes, we want to draw vertical lines on a given plot in Python matplotlib.
In this article, we’ll look at how to draw vertical lines on a given plot in Python matplotlib.
How to draw vertical lines on a given plot in Python matplotlib?
To draw vertical lines on a given plot in Python matplotlib, we can use the axvline
method.
For instance, we write
import matplotlib.pyplot as plt
plt.axvline(x=0.22)
plt.axvline(x=0.33)
plt.axvline(x=2.20)
to draw vertical lines x = 0.22
, x = 0.33
and x = 2.20
with axvline
.
Conclusion
To draw vertical lines on a given plot in Python matplotlib, we can use the axvline
method.