-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
aliasing with imshow(z, interpolation = 'none'), when saved as a pdf #2972
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
Alright, now I see why the pdf backend behaves differently with interpolation = 'nearest' vs interpolation = 'none'. When I take a large image and scale it down to fit in a small space, interpolation = 'none' preserves the resolution of the image, while interpolation = 'nearest' does nearest neighbor interpolation to the nearest pixel, which reduces image resolution. Backends that only produce images do not have this distinction. They just take whatever is on the screen and stick it in an image file, which means interpolation = 'none' and interpolation = 'nearest' are equivalent. So, I retract my earlier statement that interpolation = 'none' in the pdf backend should make the pdf look like the figure window. I like that interpolation = 'none' and interpolation = 'nearest' are different in the pdf backend. Perhaps there should be an example on matplotlib.org that shows this difference, so other users do not get confused like me. |
@stretch97 I agree it would be useful to have that documentation (this is something I actually don't know a whole lot about). Sense you have already done the leg work of understanding what is going on, would you mind drafting that documentation? |
Sure. I could put together a draft, as long as someone more knowledgable than me reviews it before we post it. |
Don't worry, it will get reviewed before it gets merged. The review process will go more smoothly if you put the edits in a pull request. |
@tacaswell Here is what I put together for an example. Others can feel free to edit this.
|
@tacaswell What do you think of my example? I am just a matplotlib user, not a matplotlib developer, so would it be easy enough for you to put it "in a pull request" for me? I can send you the "big_image.png" file. |
@stretch97 The example looks nice, however it is far easier for me if you put it in ;) I assure you almost all of the current devs started as 'just users'. If you create the PR the commits will have your name on them so you get credit for your contributions. It also makes it easy for you to respond to feed back. If it is your PR then you can just add a new commit and push it to github, if it is my PR then you have to get me to make and push any changes. I would suggest you add your example code to the gallery (the png's will be auto-generated) and add a few sentences to the docstring of See http://matplotlib.org/devel/gitwash/git_development.html If you are a mpl user, then you are writing code. If you are writing code using version control is essential, so learning git is a good idea anyway. |
Now that I have submitted a pull request (breedlun#1), this issue can be closed. The conversation can continue at the pull request. |
I am finding that matplotlib v1.3.0 will blur the edges of an image's pixels when I use interpolation = 'none' and save the image as a pdf. For example, the following code
produces the following png,
which looks just like the matplotlib figure window, as it should. However, when I save the figure as a pdf
I get the following pdf,
Perhaps this is the intended mode of operation, but IMHO the output file should look like the figure window. Fortunately, there is a work around. If use interpolation = 'nearest', everything is hunky dory:
The text was updated successfully, but these errors were encountered: