Ylim shifts image in plot

I’m trying to plot a section of an image file using Plots.jl and then draw in certain points in the image.

It works nicely when I plot the whole image:

using Plots
using FileIO, HTTP, ImageIO
bg_img2 = load(HTTP.URI("https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/GoldenGateBridge-001.jpg/640px-GoldenGateBridge-001.jpg"));

begin
	plot(bg_img2)
	scatter!([385], [315])
end

whole_image

When introducing a xlim to the plot, everything still behaves as expected:

begin
	plot(bg_img2,
		xlim=(350, 420),
	)
	scatter!([385], [315])
end

xlim

However, as soon as I introduce a ylim to the plot, the image shifts. This get apparent because the plotted point is positioned differently relative to the image.

begin
	plot(bg_img2,
		ylim=(270, 350)
	)
	scatter!([385], [315])
end

ylim

What am I missing? Or is this a bug in the plotting library?

Pluto notebook to reproduce:
ylim_image_shift.jl (43.5 KB)

I’ve done some more digging and this seems to be related to yflip=true (the default when plotting an image). Everything works as expected with yflip=false, apart from the flipped image of course.

I’ve opened a bug with Plots.jl: [BUG] `ylims` does not respect `yflip=true` · Issue #4903 · JuliaPlots/Plots.jl · GitHub

I do not see the bug in Julia Version 1.10.0, Plots v1.40.1:

PS:
You can also plot single points as tuples:
scatter!((385, 315))

Interesting, I can consistently reproduce using Julia v1.10.2, Plots v1.40.2. What code exactly did you use to make it work on your setup?

Exactly your code.

And tested now also with Plots v1.40.2, and can’t see the issue.

PS:
I run the code from VS Code on Windows.

Mysterious. I’m able to reproduce the problem on different Linux machines, as well as on Windows, in Pluto and in VS Code.

I have created another Pluto notebook as a minimal working example:
mwe_yflip_ylim_shift.jl (43.2 KB)
Is nobody else able to reproduce the issue?