How to mark specific points in a contour plot using plots.jl?

Hello,

As the title of the post says, I want to mark specific points in a contour plot in a similar way that we do in a normal plot, like in the picture below
image

The code that generated the plot:

plot(x,xV,title="Solution along y=0 direction",label=["y=0 direction" "."])
scatter!(x[xMax],xV[xMax],label=["Local Maximums" "."])

I am trying to extrapolate the same idea to a contour plot in order to get an image like this one
image

Where the red dots are the same dots that appears in the first plot. Any ideas? I’ve already tried many approaches but without success!

Cheers,
Tiago

I don’t understand why you can’t just do the exact same thing?

1 Like

More specifically, this works for me:

V(x,y) = x^2 + y^2
x = -10:0.5:10
y = -10:0.5:10
contour(x,y, (x,y)->V(x,y), levels=30)
scatter!(rand(-10:2:10, 10), [0 for _ in 1:10],label="Some points")

gives:
contour

1 Like