Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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中记号下方的某个位置绘制箭头_Python_Matplotlib - Fatal编程技术网

Python 是否可以从matplotlib中记号下方的某个位置绘制箭头

Python 是否可以从matplotlib中记号下方的某个位置绘制箭头,python,matplotlib,Python,Matplotlib,我想画一个这样的情节 棘手的是从“z=-1.48”到x轴的箭头,它位于刻度线下 下面显示的代码是我试图绘制箭头的代码 import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm fig, ax = plt.subplots(figsize=(8,3)) x = np.linspace(-5,5,101) x2 = np.linspace(-5,-1.5,101) y = norm.pdf(x)

我想画一个这样的情节

棘手的是从“z=-1.48”到x轴的箭头,它位于刻度线下

下面显示的代码是我试图绘制箭头的代码

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm

fig, ax = plt.subplots(figsize=(8,3))
x = np.linspace(-5,5,101)
x2 = np.linspace(-5,-1.5,101)
y = norm.pdf(x)
y2 = norm.pdf(x2)
t = ax.text(-3, 0.15, '-1.5')
plt.grid(True)
ax.plot(x, norm.pdf(x))
ax.fill_between(x2, 0, y2, color='r')
不幸的是,“记号”下的部分无法渲染


是否可以使勾号下的箭头显示?

是否需要
注释

ax.annotate('1.5', 
            xy=(-1.5, 0), 
            xytext=(-1.5, -0.1), 
            ha='center', 
            va='center', 
            arrowprops={'arrowstyle': '->'})
这将文本放置在
xytext
处,并从那里绘制一个指向
xy
的箭头
ha
va
是指基于这些坐标的文本对齐方式。如果您没有通过
“居中”
,箭头和文本将略微错位。最后,传递
arrowprops
可以让您受益于内置的箭头样式

有关更多信息,请参阅