I am looking for a way to project the intersection point of the graph using a vertical discontinuous line (style '--') on the x-axis and then write the x-coordinate on that axis.
Here's my attempt to find the intersection. For some reason, the point is not exactly on the intersection. It's strange.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
n = 256
k = np.arange(0, 100)
g = 1 - np.exp(-0.5 * k * (k - 1) / n)
plt.plot(g, '-')
plt.hlines(0.5, 0, 100, 'r')
idx = np.argwhere(np.diff(np.sign(g - 0.5)))
plt.plot(k[idx], g[idx], 'o')
plt.show()