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
CodePudding user response:
IIUC, something like this?
from matplotlib import pyplot as plt
import numpy as np
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:
CodePudding user response:
Use 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()