简体   繁体   English

Python matplotlib 如何在特定位置制作箭头

[英]Python matplotlib how to make arrow in specific place

Hello I have code like this:你好我有这样的代码:

from matplotlib import pyplot as plt

b = 2.8977685 * (10 ** -3)

k_range = [i for i in range(3500, 5500)]
results = [b/i for i in range(3500, 5500)]

plt.plot(results, k_range)
plt.show()

我的阴谋

And now how can I draw arron to find result in K = 4800现在我如何绘制 arron 以在 K = 4800 中找到结果

Use matplotlib.pyplot.arrow() :使用matplotlib.pyplot.arrow()

from matplotlib import pyplot as plt

b = 2.8977685 * (10 ** -3)

k_range = [i for i in range(3500, 5500)]
results = [b/i for i in range(3500, 5500)]

plt.plot(results, k_range)
plt.arrow(6E-7, 4000, 8E-8, 200, ec='red', width = 5E-12, head_width=1E-8)
plt.show()

IIUC, somethig like this? IIUC,像这样的东西?

from matplotlib import pyplot as plt

b = 2.8977685 * (10 ** -3)

k_range = [i for i in range(3500, 5500)]
results = [b/i for i in range(3500, 5500)]

k = np.array(k_range)
i = np.where(k==4800)

r=np.array(results)
r[i]

plt.plot(results, k_range, marker='x', markevery=[i[0]], markeredgecolor='r')
ax = plt.gcf().gca()
ax.annotate("", xy=(r[i], 4800), xytext=(r[i], 4400), arrowprops=dict(arrowstyle="->"))
plt.show()

Output: Output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM