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
When introducing a xlim to the plot, everything still behaves as expected:
begin
plot(bg_img2,
xlim=(350, 420),
)
scatter!([385], [315])
end
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
What am I missing? Or is this a bug in the plotting library?
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.