Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ylims does not respect yflip=true #4903

Open
pearzt opened this issue Mar 12, 2024 · 1 comment
Open

[BUG] ylims does not respect yflip=true #4903

pearzt opened this issue Mar 12, 2024 · 1 comment
Labels

Comments

@pearzt
Copy link

pearzt commented Mar 12, 2024

Details

I'm trying to "crop" a plotted image using xlims and ylims. Everything works as expected when using yflip=false, but with yflip=true (default), the image is cropped in the wrong side. Furthermore, the image is shifted relative to the plot's coordinate system (notice how the orange point seems to shift on the second plot).

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"));

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

whole_image

plot(bg_img2,
	ylim=(100, 480),
	yflip=true
)
scatter!([385], [315])

ylim

It seems to me that yflip=true is not correnctly respected when specifying ylims.

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: v1.40.2
Backend version (]st -m <backend(s)>): GR v0.73.3
Output of versioninfo():

Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 13th Gen Intel(R) Core(TM) i7-1355U
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

@pearzt pearzt added the bug label Mar 12, 2024
@tlnagy
Copy link

tlnagy commented May 21, 2024

I'm running into this bug on the latest v1.40.x series. The code worked fine on Plots v1.39 so it was a recent regression. This isn't specific to ylims/yflip either since xlims/xflip also have the same problem:

using Colors
using OffsetArrays
using Plots

p = plot(OffsetArray(rand(Gray, 11, 11), 100:110, 100:110), 
    xlim = (0, 150), ylim = (0, 150), xflip = true, yflip = true, title = "Plots $ver")
savefig(p, "plots_$(ver).png")
p

Same code running on Plots v1.39.0:

plots_v1 39 0

vs

Plots v1.40.4:

plots_v1 40 4

EDIT: Plots v1.40.0 has this error too. So it was introduced between 1.39.0 and 1.40.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants