And I would like to add a tag or pointer which point to the intersection and display the coordinates of the intersection. Something like this:
I know the coordinates of the intersection and I know that the function annotate! adds text to the plot. However, I do not know how to add an line or arrow to point to the intersection and how to determine the right position for the text.
@gustaphe’s suggestion is good. Just remember that the coordinates are data-relative (not plot display-relative). So zooming in will make the marker bigger.
Alternative using single-point dataset & marker:
You can add the marker as a simple shape that will resize itself when you zoom in. But I don’t see a way to offset the text in a display-relative manner either. Your best bet is probably to specify the alignment of the text as :bottom, :left, or something (see below):
pt = (3,9) #where to place the marker
#Add a single point using marker formatted as desired:
plot!([pt[1]],[pt[2]], markershape=:plus,
markercolor=:grey, markerstrokecolor=:black, markerstrokewidth=3,
markersize=10
)
#Annotate with x-value
ptstr = string(pt)
xvalstr = string(pt[1]) #Just x value
annotate!((pt...,text(xvalstr, 14, :bottom, :left, :green)))
The top-left marker is a single marker generated with r while hovering over the plot.
The 2 markers on the right were created with the r-d key combination.
Limitation
I don’t think there is an API yet to generate these markers programmatically, but it probably can be added without requiring a much new code (you can open a PR if this interests you).
And since you are working with frequency plots, you might be interested in knowing that InspectDR allows you to stack multiple y strips that maintains a common frequency window as you zoom in interactively.