You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
imshow pixel boundaries wrong when zoomed in #14143
imshow pixel boundaries visibly shift from expected coordinates by many pixels when zooming in, depending on dpi but not improving at high dpi.
I am trying to plot gridded data with imshow so it aligns with other plot elements like lines. When I zoom in on the image so image pixels are bigger than the plot axes, the boundaries between pixels are visibly shifted from where they ought to be. The shift depends on the dpi of the figure but cannot be resolved by changing the dpi.
This is yet more issues with your favorite part of the code base @jklymak (AxesImage ;) )
I think this is a duplicate of #1441 I still think the issue is that we are doing the re-sampling from the full input data -> the screen. If you zoom way in / turn up the DPI, we start to get numerical issues mapping back from screen space to input space.
Put another way, when you are very zoomed in we are pulling a 200 x 200 window out of a 200k x 200k notional array and the error on picking the right place to transition from input pixel A to pixel B should be evaluated against the 200K space.
I'm pretty sure this is the same issue, but I can see the same bug even without zooming in with this gridded example (on a TkAgg backend in case it matters):
Note the bunch of yellow and brighter green pixels that stretch over the grid lines.
The key difference with respect to the original example in the issue is probably that the thinner grid lines that I use no longer hide the misalignment. Just like in the suspected duplicate some of the overlaps jump around if I pan interactively, but this is not very obvious because most of the overlaps are pretty resilient to panning and only disappear in a narrow window during panning.
@QuLogic I'm not completely sure that I'm testing it right but I think the bug in my last comment is still present on main. I couldn't get an editable install to work right now, so I ended up just installing current main from github directly (plus PyQt6). I see this:
@adeak: Argh, you are correct that your issue has not been fixed. I've re-confirmed that #30184 fixed the original issue, but I apparently overlooked checking your example too. I'll look into it.
Sorry @ayshih 😅 For what it's worth this is not an issue for me today, I found this 6 years ago. So if this is a different problem we can open a dedicated issue to track it and you need not jump into it just for my sake ;)
@adeak: Based on my investigation so far, the problem in your example is indeed distinct from the original issue, and it is very important to fix. It's not a bug internal to the image-resampling code, but rather it has to do with how image placement affects what resampling is requested and how the resampled image is drawn. Can you create a dedicated issue?
Activity
jklymak commentedon May 6, 2019
Does
dpi=1000really change the dpi in the inline backend?plisdku commentedon May 6, 2019
It definitely gave me an enorrrrrrrmous png file, I can attest to that. :-) I don't know how mpl is working on the inside though.
jklymak commentedon May 6, 2019
Yes, I agree, that certainly is a bug... Thanks for the good report.
tacaswell commentedon May 6, 2019
This is yet more issues with your favorite part of the code base @jklymak (
AxesImage;) )I think this is a duplicate of #1441 I still think the issue is that we are doing the re-sampling from the full input data -> the screen. If you zoom way in / turn up the DPI, we start to get numerical issues mapping back from screen space to input space.
Put another way, when you are very zoomed in we are pulling a 200 x 200 window out of a 200k x 200k notional array and the error on picking the right place to transition from input pixel A to pixel B should be evaluated against the 200K space.
adeak commentedon Feb 11, 2020
I'm pretty sure this is the same issue, but I can see the same bug even without zooming in with this gridded example (on a TkAgg backend in case it matters):
Note the bunch of yellow and brighter green pixels that stretch over the grid lines.
The key difference with respect to the original example in the issue is probably that the thinner grid lines that I use no longer hide the misalignment. Just like in the suspected duplicate some of the overlaps jump around if I pan interactively, but this is not very obvious because most of the overlaps are pretty resilient to panning and only disappear in a narrow window during panning.
8 remaining items
adeak commentedon Aug 29, 2025
The code block from my previous comment still shows the bug on v3.10.5 (with qtagg backend here):
This should stay open.
QuLogic commentedon Jan 15, 2026
This should be fixed by #30184.
adeak commentedon Jan 15, 2026
@QuLogic I'm not completely sure that I'm testing it right but I think the bug in my last comment is still present on
main. I couldn't get an editable install to work right now, so I ended up just installing currentmainfrom github directly (plus PyQt6). I see this:The grid issue is still there. And I think I'm correctly on
main:as newest commit on
maincurrently is ddd4196.QuLogic commentedon Jan 16, 2026
Your example is different from the original issue as it very much has to do with zooming. Perhaps @ayshih has some ideas on yours.
ayshih commentedon Jan 16, 2026
@adeak: Argh, you are correct that your issue has not been fixed. I've re-confirmed that #30184 fixed the original issue, but I apparently overlooked checking your example too. I'll look into it.
adeak commentedon Jan 16, 2026
Sorry @ayshih 😅 For what it's worth this is not an issue for me today, I found this 6 years ago. So if this is a different problem we can open a dedicated issue to track it and you need not jump into it just for my sake ;)
ayshih commentedon Jan 21, 2026
@adeak: Based on my investigation so far, the problem in your example is indeed distinct from the original issue, and it is very important to fix. It's not a bug internal to the image-resampling code, but rather it has to do with how image placement affects what resampling is requested and how the resampled image is drawn. Can you create a dedicated issue?
adeak commentedon Jan 21, 2026
Sure thing @ayshih, thanks for looking into this.