-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Misalignment imshow vs. grid lines #1441
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
Comments
@rougier : You can make code blocks with three consecutive ``` (grave/backquotes). Hope you don't mind but I've edited your description to use them. |
If you interactively pan around on this example the amount that the lines miss the edges of the pixels by jumps around. I suspect that this might be related to #3057 (more beating?) and smells like snap is related, but I don't understand that well enough |
Punting this to 1.4.x as this is only visible if you zoom way in and looks like it is something subtle down at the bottom (maybe not a fast find or fix). |
I'm not objecting the increase of the milestone. I agree that it might be difficult to debug this and that one would usually not see the difference, I just wanted to note that this effect may be visible at normal magnifications as well. I spotted it at relatively normal scale when noticing that the grid was off the pixels on the image (my real-life example is very similar to #2935). What is the expected result of the example above? I'm asking because I see off-by-one error on PNG, but the PDF I get seems completely wrong. |
If I change Here's another example adapted from #2935:
Here's how the checkerboard pattern image looks, as written in the PDF file:
Note that the values are not all 00 or ff. Even with |
The bug is still present after the image refactor. |
There is some quantization going on with this. If you pan left and right the pattern 'jumps' but the grid lines move smoothly. |
The grid lines are misaligned on the x-axis. E.g.
Is there a fix for this? |
I sunk the better part of a day into this and still don't really understand it (but I as a side-effect, I think I have the start of a performance-improvement PR!).
I suspect that the issue is in how we are calling the Agg resample code, but that may just me blaming the part of the code I understand the least. |
This is about PNG, not PDF, but I wonder if your trawling into raster image rendering might give you some ideas about this, @brunobeltran. |
Oh neat, this is the error I alluded to in #6827. This is separate from all DPI-related issues actually, and has to do instead with the logic in the helper function
After I push working versions of the rounding fixes, I'll try to think harder about the "correct" way to fix this. This is related to the issue brought up by @efiring yesterday on the call, where we sometimes want to use the center of the pixel's color to decide the color, and sometimes we want the color on the edge... |
If anyone has thoughts about how this should be fixed, the easiest way to see the faulty logic is to use a trivial example:
and set a breakpoint at |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Just to add that this issue still exists on main, and I can confirm that it can be seen without the Agg renderer (cairo & another). This supports the assumption that this is a problem in the image code, rather than the renderer. I find it curious that you only see the misalignment in the y-axis, and not in the x. |
This should stay open. |
The following script show a mis-alignment between grid lines and image patterns while they should be aligned:
The text was updated successfully, but these errors were encountered: