Closed
Closed
Copy link
Description
Bug summary
When using imshow
with interpolation='none'
and then saving the figure to PDF using savefig()
, the PDF file output does not match the screen/notebook output. It appears that interpolation is still being applied to the PDF output. This bug is manifested only with 'none' interpolation with PDF filetype output. Setting interpolation
to None
or 'nearest'
gives the correct result with PDF output (and screen/file match). PNG, JPG, and SVG output filetypes all produce the correct results. MWE below.
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
data = np.zeros((25, 25))
data[8:16, 8:16] = 100
fig, ax = plt.subplots()
ax.imshow(data, interpolation='none')
fig.savefig('output.pdf')
Actual outcome
Notebook/screen output (correct):
PDF File output (incorrect):
output.pdf
Expected outcome
The output PDF file would not have interpolation applied (matching the screen output).
Additional information
No response
Operating system
macos
Matplotlib Version
3.7.1
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.11.2
Jupyter version
6.5.3
Installation
pip