Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在matplotlib中添加平行于y轴的线?_Python_Matplotlib - Fatal编程技术网

Python 如何在matplotlib中添加平行于y轴的线?

Python 如何在matplotlib中添加平行于y轴的线?,python,matplotlib,Python,Matplotlib,我想在x=c#constant处画一条线 这应该很简单,但我该怎么做呢 您可以使用 使用matplotlib.pyplot的axvline方法: import matplotlib.pyplot as plt plt.axvline(x=0.5) 您还可以设置y值的范围: plt.axvline(x=0.5, ymin=0.2, ymax=0.4) ymin=0和ymax=1的默认值是指x=2,x=3等吗? plt.axvline(x=0.5, ymin=0.2, ymax=0.4)

我想在
x=c#constant
处画一条线

这应该很简单,但我该怎么做呢

您可以使用


使用
matplotlib.pyplot
axvline
方法:

import matplotlib.pyplot as plt

plt.axvline(x=0.5)

您还可以设置y值的范围:

plt.axvline(x=0.5, ymin=0.2, ymax=0.4)


ymin=0
ymax=1

的默认值是指
x=2
x=3
等吗?
plt.axvline(x=0.5, ymin=0.2, ymax=0.4)