1

I have a plot with intersecting lines:

Plot

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:

Tag example

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 a line or arrow to point to the intersection and how to determine the right position for the text.

Velitar
  • 21
  • 3

1 Answers1

2

I agree that this isn't the most user-friendly thing to do, but I think it's also not that easy to implement (fwiw when I do this in practice I often resort to just exporting to PowerPoint and then annotating the plot there manually) - but here's a way to do it:

julia> using Plots

julia> plot(x -> x^2, 0:0.01:2); hline!([1], color = :red, linestyle = :dash); vline!([1], color = :green, linestyle = :dash)

julia> quiver!([0.5], [2], quiver = ([0.475], [-0.95]))

julia> annotate!([0.5], [2.1], text("This point is (1,1)"), valign = :top)

enter image description here

Nils Gudat
  • 13,222
  • 3
  • 39
  • 60