I want to draw a line at x=c #constant
.
This should be pretty straightforward, but how can I do it?
You can use matplotlib.pyplot.axvline()
.
import matplotlib.pyplot as plt
plt.figure()
plt.axvline(x=0.2)
plt.axvline(x=0.5)
plt.show()
Using matplotlib.pyplot
's axvline
method:
import matplotlib.pyplot as plt
plt.axvline(x=0.5)
You can also set range for the y value:
plt.axvline(x=0.5, ymin=0.2, ymax=0.4)
Default value for ymin = 0
and ymax = 1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With